home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5 / rexx.ref < prev    next >
Encoding:
Text File  |  1993-06-25  |  149.7 KB  |  3,468 lines

  1. The REXX Interpreter (Experimental Version)
  2.  
  3. This is a reference for the various language features supported by the
  4. REXX/imc interpreter.  An introduction, summary and technical reference
  5. may be found in rexx.info, rexx.summary and rexx.tech, respectively.
  6.  
  7. Oxford Note: There are two versions of the REXX/imc executable file, for
  8.       sun3 and sun4 architectures: these are kept in /mclab/imc/sun3/rexx
  9.       and /mclab/imc/sun4/rexx respectively.  An executable shell script
  10.       is kept in /mclab/imc/misc/rexx; this invokes the appropriate
  11.       binary file.  Unfortunately, placing "#!/mclab/imc/misc/rexx" at
  12.       the top of a Rexx program does not work because it is not a binary
  13.       file.      
  14. _________________________________________________________________________
  15.  
  16. Invocation:   rexx [flags] filename args
  17.  
  18. where "filename" is the name of the REXX program you wish to execute,
  19. and "flags" are some optional commandline parameters, described later.
  20.  
  21. Notes:
  22.  
  23. 1. If the basename of "filename" does not contain a dot, then an
  24.    interpreter-supplied extension (usually ".exec") will be appended,
  25.    and will become the "default extension". Otherwise, nothing will be
  26.    appended and the given name's extension will become the default
  27.    extension (the default extension is referenced when calling external
  28.    functions).
  29.  
  30. 2. The argument string may be any sequence of characters, including
  31.    spaces, but not including NULs (\0). Bear in mind that quotes and/or
  32.    escape characters may be necessary, because the csh shell interprets
  33.    some characters as special and removes multiple spaces.
  34.  
  35. 3. The REXX program is assumed to be a text file whose lines are
  36.    separated by newline characters: thus newline characters may not
  37.    appear in the middle of a line.  All other characters are allowed
  38.    (but many characters are rejected unless they form part of a string
  39.    constant or comment). 
  40.  
  41. 4. If the given filename does not include a path specification, then
  42.    the interpreter will search through the directories listed in the
  43.    PATH environment variable (if any), before looking in the current
  44.    directory.  The current directory may be placed in PATH to change
  45.    this searching order (but this is disrecommended because it is a
  46.    possible security risk in Unix).
  47.  
  48. Thus "rexx -ta test hello there" will call the program "test.exec" with
  49. argument "hello there" and flag "-ta".
  50.  
  51. The flags which are allowed all start with a "-" and are case-
  52. insensitive.  They are:
  53.  
  54.   -option    where "option" is any option recognised by the OPTIONS
  55.              instruction (see below), for example: -tracefile=test1
  56.  
  57.   -s string  The interpreter will execute the contents of "string" as
  58.          though it were a program.  The string may contain newline
  59.          characters, which will be recognised as line terminators
  60.          (in contrast to the string which appears in an INTERPRET
  61.          instruction). Note that if the string contains any shell
  62.          metacharacters (including spaces) then it must be quoted
  63.          to prevent the shell from interpreting it or splitting it
  64.          up.
  65.  
  66.   -t setting The interpreter will execute "TRACE setting" before
  67.              interpreting the program.  The space before the setting
  68.          may be omitted, for example: -t?i.  Note that the setting
  69.          may need to be quoted, because "?" is a shell
  70.          metacharacter.
  71.  
  72.   -i         This equals "-t?a -s 'do forever;nop;end'".  The interpreter
  73.              will enter interactive mode for you to type Rexx
  74.          instructions.
  75.  
  76.   -x         This option is used for files with the execute bit set on:
  77.              it prevents an ".exec" from being appended to the
  78.          filename, and it causes the first line of the file to be
  79.          ignored (see below).
  80.  
  81. Except in the case that -i or -s is present, if a filename is omitted
  82. or "-" is specified then REXX/imc reads a program from the standard
  83. input.
  84.  
  85. The option "-x" and the filename "-" terminate the commandline flags.
  86. The following parameter is assumed to be a filename (except when -i, -s
  87. or - have been specified) followed by the Rexx program parameters.  To
  88. execute a program called "-", say "rexx -x -".
  89.  
  90. REXX/imc allows you to write a program starting with the line:
  91.  
  92. #!/path/rexx -x
  93.  
  94. (where /path/rexx is the absolute path name of the interpreter) at the
  95. top of the file so that the program can be made executable by the
  96. system.  REXX/imc will ignore the above line (as it doesn't make sense
  97. in REXX) because of the -x supplied as an option. The line will still
  98. be there, however, so line numbers in error reports will be correct
  99. (the `sourceline' function will also recognise the existence of this
  100. line).  In fact REXX/imc always ignores the first line if it starts
  101. with the characters "#!", but using the -x parameter allows a further
  102. trick: in order to write a rexx program which is able to be executed on
  103. either a sun3 or a sun4, the first line of the program should not be as
  104. above, but as follows:
  105.  
  106. exec rexx -x "$0" "$*"
  107.  
  108. as long as "rexx" can be found in a directory which is on the current
  109. path.
  110.  
  111. Oxford note: instead of the above, the following line specifies the
  112.              correct path name:
  113.  
  114. exec /mclab/imc/`/bin/arch`/rexx "$0" "$*"
  115.  
  116. The Rexx interpreter needs access to the program "rxque" and (if math
  117. functions are called) "rxmathfn.*" (where * is either exec or rxfn).
  118. The interpreter has several places to look for these files, and it will
  119. use the first directory in which it finds "rxque" at initialisation
  120. time. (Note: this means that changing the value of REXXIMC while the
  121. interpreter is running has no effect).  The interpreter will search for
  122. "rxque" in the following directories:
  123.  
  124.  - that named by REXXIMC, if this environment variable is set.  If it
  125.    is not set, then a default which was chosen at compile time is used
  126.    instead.
  127.  - the path name used when invoking Rexx, if any.  That is, if you type
  128.    "/foo/rexx myexec", then /foo will be searched.  If you type
  129.    "rexx myexec", then this step will be skipped.
  130.  - the directories named in the environment variable PATH
  131.  - the current directory.
  132.  
  133. It should not be necessary to set REXXIMC, but under certain
  134. circumstances it may speed up the initialisation time to do so.
  135. _________________________________________________________________________
  136.  
  137. The REXX Language, as interpreted by this implementation
  138. ========================================================
  139.  
  140. NOTE:  There will occasionally be comments headed by `NOTE', `BUG' or
  141.        `LOCAL'. The notes following these will usually be in the
  142.        following categories:
  143.     NOTE - (semi-)important information, pointing out traps or
  144.            differences with other implementations.
  145.     BUG  - a feature of the program (not always a particularly bad one,
  146.            though never beneficial) which may not get fixed.
  147.     LOCAL- a feature of the interpreter which I have deliberately added
  148.            and is not `real' REXX
  149.  
  150. NOTE:  Just because any particular description does not contain a note
  151.        headed by `LOCAL', that does not necessarily mean that the
  152.        relevant function behaves exactly according to the REXX
  153.        specification. It does mean, however, that I would like to know
  154.        of such instances where there is a difference, so that I can
  155.        either change the program or add a note to describe the
  156.        behaviour.
  157.  
  158. The use of non-implemented REXX constructs will produce either error 82
  159. (Syntax error) or error 81 (Un-implemented function).
  160. _________________________________________________________________________
  161.  
  162. Summary:
  163.  
  164. Expressions
  165. Built-in functions
  166. Instructions:
  167.    NOP
  168.    SAY, SAYN (local)
  169.    Assignment
  170.    DROP
  171.    NUMERIC
  172.    EXIT
  173.    DO
  174.    LEAVE
  175.    ITERATE
  176.    IF
  177.    SELECT
  178.    PARSE
  179.    QUEUE, PUSH
  180.    CALL (and function calls)
  181.    RETURN
  182.    PROCEDURE
  183.    INTERPRET
  184.    SIGNAL
  185.    SIGNAL ON
  186.    TRACE
  187.    OPTIONS
  188.    ADDRESS
  189. Commands to the environment
  190. The REXX I/O model
  191. The stack
  192. Error messages
  193. _________________________________________________________________________
  194.  
  195. Expressions
  196.  
  197. Every expression evaluates to a string. There are no numeric expressions,
  198. but arithmetic may be performed on those strings which happen to
  199. represent numbers in decimal. From here on, references to "numbers" or
  200. "numeric" values will mean strings of the following format:
  201.    [+|-] [nnnnn][.][nnnn] [E [+|-] nnn]
  202. That is, an optional sign followed by a string of digits, possibly
  203. including a decimal point, followed by an optional exponent. The exponent
  204. consists of a letter `E' (or `e'), an optional sign, and a sequence of
  205. digits. No spaces are allowed within a number, but trailing or leading
  206. spaces are allowed, and spaces may occur between the leading sign and the
  207. first digit. There is no number which contains no digits before the
  208. exponent (if any), and "." is not a number.
  209.  
  210. Whenever REXX constructs a number (such as the result of an arithmetic
  211. operation), it is formatted according to the following rules:
  212.  
  213.    - a zero result is always expressed as the single digit "0".
  214.    - it is rounded up or down if necessary, so that the specified number
  215.      of significant figures is not exceeded. The number of significant
  216.      figures is usually 9, but can be changed with the NUMERIC DIGITS
  217.      instruction.
  218.    - If the number is negative, it is preceded by a minus sign, otherwise
  219.      there is no sign. A number never contains spaces.
  220.    - If the magnitude of the number is less than 1 (and if exponential
  221.      notation is not used) then a single zero digit precedes the
  222.      decimal point.
  223.    - An exponential form of the number - e.g. 1.234E+65 - will be used
  224.      if the number of digits otherwise required before or after the
  225.      decimal point exceeds NUMERIC DIGITS or twice that value,
  226.      respectively.
  227.    - If NUMERIC FORM SCIENTIFIC is in effect (the default) and the
  228.      number is expressed in exponential form, then the mantissa has
  229.      precisely one digit before the decimal point (if any), which is
  230.      non-zero. The exponent consists of the letter E followed by a plus
  231.      or minus sign, and then the exponent (with no spaces or leading
  232.      zeros).
  233.    - If NUMERIC FORM ENGINEERING is in effect and the number is
  234.      expressed in exponential form then the exponent is a multiple of
  235.      three. Up to three digits appear before the decimal point in the
  236.      mantissa, but otherwise the form is similar to the `scientific'
  237.      form described above.
  238.  
  239. See the NUMERIC command for some more information.
  240.  
  241. An expression consists of one or more constants or variables which
  242. may be combined with the use of operators and functions, as described
  243. below. Spaces are allowed within expressions, as long as they do not
  244. split up variable names or other integral items.
  245.  
  246. String Constants: These are enclosed in quotes. Either single or double
  247.              quotes may be used, but the terminating quote must be the
  248.              same as the initial quote. A string may contain any
  249.              characters, but to enclose a quote of the same
  250.              kind as the delimeters, the quote is typed twice.
  251.              A string containing no characters is a null string.
  252.              Example:
  253.                  "that's right"          has value   that's right
  254.                  '"I''m here," I said.'  has value   "I'm here," I said.
  255.                  ""                      is the null string.
  256.  
  257. Hex Constants:    A hex constant contains a sequence of hex digits
  258.              grouped in pairs. The first group may have just one digit,
  259.              in which case a `0' is added to the left. The groups are
  260.              optionally separated by spaces. Each group (pair) of hex
  261.              digits is translated into the character it represents in
  262.              ASCII. The list is enclosed in quotes and immediately
  263.              after the terminating quote is an `X' (or `x'). The `X'
  264.              must not form part of a longer word.
  265.              Example:
  266.                  "41 4243   44 "x        has value   ABCD
  267.  
  268. Binary Constants: A binary constant is like a hex constant, but has `B'
  269.              instead of `X' and contains binary digits ("0" or "1").
  270.          The digits are arranged in nybbles - that is, groups of 4,
  271.          which may optionally be separated by spaces.  The first
  272.          nybble may have less than 4 digits, in which case it is
  273.          extended on the left with zeros.  If an odd number of
  274.          nybbles is present, a zero nybble is added on the left.
  275.          Each pair of nybbles is then translated into an ASCII
  276.          character.  Example:
  277.                  '10 0011 00100001'b     has value   CA
  278.  
  279.          NOTE: the sequence of binary or hex digits must not contain
  280.                leading or trailing blanks.
  281.  
  282. Symbols:          A symbol contains any number of letters, numbers, dots
  283.              and the characters @#$!?_ and is always translated to upper
  284.              case before use. A constant symbol is one which starts with
  285.              a number or a dot, and when it is found in an expression,
  286.              the characters of the symbol itself are used. In addition, a
  287.              single plus or minus sign is allowed in a constant symbol
  288.              if it is part of (the exponent of) a number as defined above
  289.                   Any non-constant symbol may be assigned a value by the
  290.              statement
  291.                        symbol = expression
  292.                   A simple symbol is one which does not contain any dots
  293.              and does not start with a digit. When it is used in an
  294.              expression it names a variable, and if it has been assigned
  295.              a value then that value is used, otherwise the symbol itself
  296.              is used (after translating to upper case).
  297.                   A stem is a symbol which ends with a dot, but does not
  298.              contain any other dots and does not start with a digit or
  299.          dot.  It can be used in an expression or assigned to (see
  300.          below).
  301.                   A compound symbol is a symbol which consists of a stem
  302.              followed by a tail. The tail consists of a non-empty
  303.              sequence of `qualifiers' separated by dots. Each qualifier
  304.              is ordinarily a simple symbol, a constant symbol, or null
  305.              (that is, it contains no characters), but as a LOCAL
  306.              extension, some additional qualifiers are allowed.  The
  307.          following can be used as qualifiers:
  308.               1. a simple symbol, which is substituted by its value
  309.                  before being used in the compound variable name
  310.               2. a constant symbol, which is uppercased before being used
  311.                  in the compound symbol
  312.               3. a null qualifier (as in `a..b')
  313.               4. a string constant
  314.               5. a parenthesised expression.
  315.              The stem and all qualifiers (1) and (2) above are uppercased
  316.              before use, but the value of a symbol in (1) or of a string
  317.              constant or expression in (4) or (5) is not uppercased.
  318.                   After the name of a compound symbol has been found, if
  319.              it has a value then that value is used, otherwise the name
  320.              of the symbol is used (with no uppercasing).
  321.               If a stem is assigned a value (as in `foo.=7'), then
  322.              every possible compound symbol is given that value (so, for
  323.          example, foo.bar now has value 7).  If a stem is used in an
  324.          expression, its value will be the last value assigned to the
  325.          stem, if any (and otherwise its value will be the stem's
  326.          name in uppercase).  So, for example, foo. now has value 7.
  327.  
  328.              Examples:
  329.              If foo has been assigned the value 5 but no other names have
  330.              been assigned values, then:
  331.                 foo is a simple symbol with a value
  332.                 foobar is a simple symbol without a value
  333.              and
  334.                 foo.5
  335.                 foo.Foo
  336.                 FOO.'5'
  337.                 foo.(foo*3-10)
  338.              all represent the same compound symbol (which has no value,
  339.              so the string "FOO.5" will be used).
  340.              However,
  341.                 foo.'bar'
  342.                 foo.'BAR'
  343.              represent different compound symbols, each of which has no
  344.              value (so the strings "FOO.bar" and "FOO.BAR" will be used
  345.              respectively).
  346. LOCAL:       Note that qualifiers (4) and (5) above are local extensions.
  347.  
  348. Literals:         A literal is another name for a constant symbol, or a
  349.              non-constant symbol without a value.
  350.  
  351. BUG:  There is an upper limit on the length of variable names. If at any
  352.       time during the interpretation of a variable name the interpreter's
  353.       copy of the name is likely to exceed about 250 characters, there
  354.       will be an error.
  355.  
  356. Operators:
  357.  
  358. Each operator described below will be given a priority. Operators are
  359. applied, from left to right, in order of their priority, 1 being
  360. carried out last. Thus, in "3+4*5/2" the operations carried out are, in
  361. order:
  362.    4*5=20  (priority 8)
  363.    20/2=10 (priority 8)
  364.    3+10=13 (priority 7)
  365.  
  366. Unary operators:  + 11  (+a is similar to 0+a)
  367.                   - 11  (arithmetical negation)
  368.                   ^
  369.               or  \ 11  (boolean negation)
  370. Binary operators: **10  (exponentiation)
  371.                   *  8  (multiplication)
  372.                   /  8  (division)
  373.                   %  8  (integer division)
  374.                   // 8  (remainder from integer division)
  375.                   +  7  (addition)
  376.                   -  7  (subtraction)
  377.                   || 6  (concatenation)
  378.                   =  5  (equality)
  379.                   == 5  (strong equality)
  380.                   <>
  381.               or  ><
  382.               or  ^=
  383.               or  \= 5  (not equality)
  384.                  ^==
  385.                  \== 5  (strong nequality)
  386.                   <  5
  387.                   <=
  388.               or  ^>
  389.               or  \> 5  (the usual relations)
  390.                   >  5
  391.                   >=
  392.               or  ^<
  393.               or  \< 5
  394.                   >> 5  (strong greater-than)
  395.                   << 5  (strong less-than)
  396.                  >>=
  397.               or ^<<
  398.               or \<< 5  (strong greater-or-equal)
  399.                  <<=
  400.               or ^>>
  401.               or \>> 5  (strong less-or-equal)
  402.                   &  3  (boolean and)
  403.                   |  2  (boolean or)
  404.                   && 2  (boolean xor)
  405.  
  406. NOTE: The character `\' and the character `^' both mean `not' and
  407.       are interchangeable.  The preferred `not' character is `\'.
  408.  
  409. In addition to these binary operations, there are two concatenation
  410. operators. Firstly, if two values are placed next to each other with
  411. no space in between (clearly they must be differentiable for this to
  412. make sense), they are concatenated, with priority 6. Secondly, if two
  413. values are placed next to each other with at least one space between,
  414. they are concatenated with a space between, with priority 6.
  415.  
  416. For example, 1"+"1"="1+1             has value   1+1=2
  417.              1    "+" 1   "="1+1     has value   1 + 1 =2
  418.  
  419. NOTE: There are a small number of cases where the space operator does
  420.      not give the intended result. Example:
  421.          1  -2   4   -7       does not equal 1 -2 4 -7
  422.                               but it equals  -1 -3
  423.      because spaces are allowed within expressions, and so this
  424.      expression is interpreted as meaning
  425.          1-2  4-7
  426.  
  427. Parentheses are used in order to circumvent the usual priorities of
  428. operators, so that, for example, (1+2)*3 is 9, whereas 1+2*3 is 7.
  429.  
  430. A function call consists of a function name (which is a symbol)
  431. followed immediately by a left parenthesis, a list of expressions
  432. separated by commas, and a right parenthesis. Arguments may be omitted
  433. simply by putting no expression between one comma (or parenthesis) and
  434. the next. As with simple symbols, the case of the function name is
  435. ignored unless it is a string constant. Note that a function name must
  436. not end with a dot, because in that case it would be interpreted as a
  437. compound symbol containing a parenthesised expression.
  438.  
  439. There are three types of function, which are searched in the following
  440. order:
  441.   1. Internal functions (those in the current program, beginning with a
  442.      label). These are not searched if the function name is a string
  443.      constant.
  444.   2. Built-in functions (a list of which is given later in this section).
  445.      Note that if the function name is a string constant, it must be in
  446.      upper case for the search to succeed.
  447.   3. External functions (either an external executable file or an
  448.      external rexx program).  When an external function file is searched
  449.      for, the name is always translated to lower case.  If the name is a
  450.      string constant then a path name may be specified.  The search is
  451.      caried out three times, once with ".rxfn" appended, once with the
  452.      default extension (see invocation section above), and once with
  453.      ".exec".  If the ".rxfn" file is found, it is assumed to be an
  454.      executable which will be dynamically linked in with the
  455.      interpreter.
  456.  
  457. NOTE: Once an executable function has been found, it becomes in effect a
  458.       built-in function.  When the interpreter is searching for such a
  459.       function, the name is not translated to lower case, and any
  460.       leading path name is ignored.  However, the name of the function
  461.       (i.e. that part which comes after the last slash) will usually be
  462.       required to be in upper case - so "/my/directory/FUNCTION" is the
  463.       preferred way to name a function in /my/directory.
  464. NOTE: The above notes about case translation will change in the future.
  465.  
  466. Examples:
  467.   foo(3,,6)    calls an internal or built-in function named FOO, or an
  468.                external function named foo or foo.exec, with arguments
  469.                3,nothing,6.
  470.   'DATE'()     always calls the built-in function DATE with no arguments.
  471.   "/bin/ABC"() calls an external function named /bin/abc.rxfn or
  472.                /bin/abc.exec (perhaps).
  473.  
  474. Arithmetic Operators:
  475.  
  476.   The operand(s) must be numeric values. If they are not, then an error
  477. results.
  478.   The usual arithmetic rules apply. See the "NUMERIC" command.
  479.   The y operand the exponentiation operator in "x ** y" must be an
  480. integer, otherwise an error results. The exponentiation operator works
  481. effectively by multiplying x by itself y times, and taking the
  482. reciprocal if y<0. (It uses an O(log y) method).
  483.   The integer division operator % is defined so that x%y is the integer
  484. part of x/y (obtained by rounding towards zero), and x = y*(x%y) + (x//y)
  485. For example, 10 % 0.3 = 33  and  10 // 0.3 = 0.1
  486.   An integer is a whole number which lies within the range of the machine
  487. (-2**31 to 2**31-1).  A whole number is any number with no non-zero
  488. fractional part which would not be written in exponential notation when
  489. formatted.
  490.   The maximum exponent is about 999999999. An overflow or underflow
  491. will occur if the limit is exceeded.
  492.  
  493. BUG:  You might find that the maximum number boundary is a little `fuzzy'
  494.       but if you keep below 1E999999990 you should be alright!
  495. BUG:  Whole numbers must be less than 1999999999.
  496.  
  497. Boolean logic:
  498.  
  499. Several of the above operators operate on boolean values or create
  500. boolean values. The following rules apply:
  501.  
  502. 1. The result of a binary relation or of the \ (or ^) operator is always
  503.    1 for true, 0 or false.
  504. 2. A boolean value is represented by any number (attempts to use other
  505.    strings will result in an error). False is represented by zero, and
  506.    any other number represents true.
  507.  
  508. LOCAL: In `real' REXX a boolean value may only be represented by 0 or 1.
  509.  
  510. 3. \x has the obvious meaning consistent with the above (i.e. 1 if x=0,
  511.    and 0 otherwise).
  512. 4. x & y   is 0 if y is false but has the same value as x when y is true.
  513. 5. x | y   is 1 if y is true but has the same value as x when y is false.
  514. 6. x && y  has value x if y is false, and \x otherwise.
  515.  
  516. Binary relations:
  517.  
  518. (note that the symbol '\' means `not' and may be placed before any of the
  519. relations to negate its value, e.g. \=, \>> etc. Thus, for instance,
  520. \> and <= have the same meaning, as do \>> and <<=, etc.  The character
  521. `^` is a synonym for '\' - so ^== is the same as \==).
  522.  
  523. The operators ==, \==, <<, >>, <<=, >>= compare their two operands
  524. character by character and thus have the normal meaning of string
  525. equality, greater, less, etc.
  526.  
  527. All other operators depend on whether or not both operands are numeric.
  528. If they are, then they are subtracted and the result compared with zero.
  529. Otherwise, leading and trailing spaces are stripped and the operations
  530. are compared as strings usually are, with the shorter string being
  531. padded on the right with spaces before the comparison.
  532.  
  533. Hence:  "0.10"    \== "1e-1"        (strict string comparison)
  534.         "0.10"     =  "1e-1"        (numeric comparison)
  535.         "  hello" \== "hello  "     (strict comparison respects spaces)
  536.         "  hello"  =  "hello  "     (weak comparison strips spaces)
  537.         "abc "     >> "abc"         (strict comparison respects spaces)
  538.         "61626300"x < "616263"x     (the latter is padded with a space)
  539.         "61626364"x > "616263"x     (ordinary string comparison)
  540.         "2.5"       > "10abc"       (string comparison)
  541.         "2.5"       < "10"          (numeric comparison)
  542.         "2.5"      >> "10           (strict string comparison)
  543.  
  544. In this implementation, character comparisons are unsigned, that is to
  545. say "ff"x is greater than "00"x, etc.
  546.  
  547. _________________________________________________________________________
  548. Built-In Functions
  549.  
  550. In this section, several of the function arguments are named with the
  551. following conventions:
  552.  
  553.  "number"   must be numeric.
  554.  "length"   must be a non-negative whole number.
  555.  "count"    must be a non-negative whole number.
  556.  "position" must be a positive whole number.
  557.  "pad"      must be a string of length 1.
  558.  "option"   must be a nonempty string.  Only the first character of the
  559.             option is significant, and it is translated to uppercase
  560.         before use.
  561.  "file"     must be the name of a stream.  This can be any nonempty
  562.             string which does not contain NUL characters ('0'x).
  563.  
  564.  
  565. ABBREV(information,info[,length])
  566.  
  567. This returns 1 if info is a valid abbreviation of information - that is,
  568. info is a prefix of information and its length is at least that specified
  569. by the optional third argument (whose default is the length of info). If
  570. the length given is zero, then a null string is a valid abbreviation of
  571. anything.
  572.  
  573. ABS(number)
  574.  
  575. The magnitude of the given number is returned
  576.  
  577. ADDRESS()
  578.  
  579. The current environment string is returned (see ADDRESS instruction).
  580.  
  581. ARG([position][,option])
  582.  
  583. This function deals with the argument(s) passed into a REXX program,
  584. function or subroutine. With no parameters, the result is the number of
  585. arguments given; that is, the position of the last explicitly specified
  586. argument. If the parameter "position" is given, then the result is the
  587. "position"th argument string, or an empty string if the argument was
  588. not supplied. If the option is supplied, its first character must be
  589. "E" or "O", standing for "Exists" or "Omitted" respectively. The result
  590. of the function is then 0 or 1, depending on whether the "position"th
  591. argument string exists or was omitted, with 1 meaning that "option" is
  592. true.
  593.  
  594.   Example: if a rexx function was called by: 
  595.          foo(5,,7)
  596.   then   arg()      = 3
  597.          arg(1)     = 5
  598.          arg(2,'e') = 0
  599.  
  600. BITAND(string1[,[string2][,pad]])
  601. BITOR (string1[,[string2][,pad]])
  602. BITXOR(string1[,[string2][,pad]])
  603.  
  604. These functions perform bitwise AND, OR or XOR respectively on their
  605. two string arguments (if the string2 argument is omitted, the null string
  606. is used). Before the operation, the shorter of the two string arguments
  607. is padded with the pad character. If no pad character is given, then
  608. '00'x is used for OR and XOR, and 'FF'x is used for AND (so that the
  609. extra characters remain unchanged after the operation). The operation
  610. is carried out by combining each character of string1 with the
  611. corresponding character of string2 as appropriate, and the resulting
  612. string of characters is returned.
  613.  
  614. C2X, C2D, B2X, B2D, D2C, D2B, D2X, X2C, X2D:
  615.  
  616. Each of these is a function taking an argument and possibly a count and
  617. returning a conversion of that argument. Each function converts an
  618. argument of a type indicated by the first character of the function name
  619. (Character, heX, Binary or Decimal) into the type indicated by the last
  620. character of the name.
  621.  
  622.  Examples: c2x("abc") = "616263"   d2x(286)="11E"
  623.            d2c(65)="A"             d2b(65)="01000001"
  624.  
  625. BUG: Each of the conversion functions which deal with decimal numbers is
  626.      restricted to inputs which have a value of less than 2**31 when
  627.      converted to an unsigned integer.
  628.  
  629. Details of these functions are below:
  630. .........................................................................
  631.  
  632. B2D(binary)
  633.  
  634. The binary input, which contains only '0' and '1' characters, is
  635. converted into a non-negative decimal number.
  636.  
  637. B2X(binary)
  638.  
  639. The binary input, which contains only '0' and '1' characters, is
  640. converted into hex digits. The length of the result is the smallest
  641. possible even number.
  642.  
  643. D2B(decimal)
  644.  
  645. The decimal input is converted into binary. The length of the result is
  646. the smallest possible multiple of 8.
  647.  
  648. C2X(string)
  649.  
  650. The n-character string is converted into 2n hex digits.
  651.  
  652. C2D(string[,length])
  653.  
  654. The string is converted into a decimal number, interpreting the leftmost
  655. character as the most significant byte.  If length is omitted, then the
  656. whole string is converted and the result is positive. If the length is
  657. given, then the string is truncated or padded with zero bytes on the
  658. left to give a string of this length, and is then taken to be a twos
  659. complement number. In this case the result may therefore be negative.
  660.  
  661. D2C(decimal[,length])
  662.  
  663. The decimal number is converted into a string of characters (with the
  664. leftmost character being the most significant). If the length is given,
  665. then the result is truncated or sign-extended on the left to be of this
  666. length.  Otherwise the length of the result is such that the leftmost
  667. character is not '00'x (for positive numbers) or 'FF'x (for negative
  668. numbers) except in the case of zero, which is converted to '00'x.
  669.  
  670. D2X(decimal[,length])
  671.  
  672. The decimal number is converted into a hex number.  If the length is
  673. given, then the result is truncated or sign-extended on the left to be
  674. of this length.  Otherwise the length of the result is such that for
  675. positive numbers there is no leading zero, and for negative numbers
  676. there is no leading 'F' except in the case when the next hex digit is
  677. less than 8. D2X(0) returns a single zero digit.
  678.  
  679. X2B(hex)
  680.  
  681. Each pair of digits in the given hex string is converted to eight
  682. binary digits and these are concatenated together.  Spaces are optional
  683. between pairs of hex digits, and the first "pair" of digits may contain
  684. only one digit, in which case a leading '0' is assumed.
  685.  
  686. X2C(hex)
  687.  
  688. The hex string is converted to characters, just as when 'hex'x is typed.
  689. Spaces are optional between pairs of hex digits, and the first byte of
  690. the string may optionally contain only one digit, in which case a
  691. leading '0' is assumed.
  692.  
  693. X2D(hex[,length])
  694.  
  695. The hex string, which should contain only hex digits (and no spaces) is
  696. first truncated or extended with zeros on the left to be of the given
  697. length if necessary, and then converted into a decimal number.  If the
  698. length is given, then the hex is assumed to be in twos complement
  699. notation.  Otherwise the result will always be nonnegative.
  700. .........................................................................
  701.  
  702. CENTER(s,length[,pad]) 
  703. CENTRE(s,length[,pad])
  704.  
  705. This function returns a string of the given length containing s. If s
  706. contains fewer than the required number of characters, then pad
  707. characters (pad, or by default, blanks) are added on each side to
  708. centre s in the result, otherwise characters are taken away from each
  709. side of s leaving the middle block of characters. If an odd number of
  710. characters needs to be added or taken away, then the right-hand side
  711. loses or gains one more than the left.
  712.  
  713. CHARIN([file] [,[position] [,count]])
  714.  
  715. Reads characters from a file. See the section on the REXX I/O model.
  716.  
  717. CHAROUT([file] [,[string] [,position]])
  718.  
  719. Writes characters to a file. See the section on the REXX I/O model.
  720.  
  721. CHARS([file])
  722.  
  723. Finds the number of characters available for reading. See the section on
  724. the REXX I/O model.
  725.  
  726. CLOSE(file)
  727.  
  728. Closes a file. See the section on the REXX I/O model.
  729.  
  730. COMPARE(s1,s2[,pad])
  731.  
  732. The strings s1 and s2 are compared, after first making them of equal
  733. length by adding pad characters (or spaces) to the right of the shorter.
  734. The result is 0 if the strings are identical, otherwise the position of
  735. the first character at which the strings disagree.
  736.  
  737. CONDITION([option])
  738.  
  739. This function returns information about the current trapped condition
  740. (see "SIGNAL ON" and "CALL ON" for more information).  If there is no
  741. such condition, then an empty string is returned.  If the option is
  742. present, it must be one of the following:
  743.  
  744.    'C': Returns the condition which was trapped (one of "SYNTAX",
  745.     "ERROR", "HALT", "NOVALUE", "FAILURE" or "NOTREADY").
  746.    'D': Returns a description of the event which caused the condition.
  747.     For "ERROR" and "FAILURE", this is the command string which
  748.     resulted in error or failure.  For "NOTREADY" it is the name of
  749.     the stream which was not ready.  For "NOVALUE" it is the
  750.     derived name of the variable which has no value.  For "HALT" it
  751.     is the Unix name of the signal which caused the interruption.
  752.     For "SYNTAX" it is the error message which would have been
  753.     displayed on the terminal if the error had not been trapped.
  754.    'I': Returns the instruction name "CALL" or "SIGNAL" as appropriate
  755.     to describe how the condition was trapped.
  756.    'S': Returns the current status of the condition as "ON", "OFF" or
  757.         "DELAY".
  758.  
  759. If the option is omitted then 'I' is assumed.
  760.  
  761. COPIES(s,count)
  762.  
  763. This function returns a string consisting of "count" copies of the
  764. string s concatenated together.
  765.  
  766. DATATYPE(string[,option])
  767.  
  768. This function tests the datatype of the string. If the function is called
  769. with just one argument, then the function returns "NUM" if the argument
  770. is a valid number, and "CHAR" otherwise.
  771.  
  772. If both arguments are supplied, then the answer is a logical value
  773. (0 or 1) indicating whether or not string is of the type given by the
  774. option.  Is s is an empty string then the answer is always 0 unless
  775. testing for a hex constant (the null string is a valid hex constant).
  776. The option must be one of the following:
  777.  
  778.    'A': s is alphanumeric (containing characters only from the ranges
  779.         "a-z", "A-Z" and "0-9")
  780.    'B': s contains bits (all characters 0 or 1)
  781.    'L': s is lower case (containing only "a-z")
  782.    'M': s is mixed case (containing only "a-z" and "A-Z")
  783.    'N': s is a valid number
  784.    'S': s contains characters valid in symbols (variables)
  785.    'U': s is upper case (containing only "A-Z")
  786.    'W': s is a whole number
  787.    'X': s satisfies the rules for a hex constant (i.e. contains only
  788.         "0-9", "a-f", "A-F" and blanks in appropriate places).
  789.  
  790. DATE([option])
  791.  
  792. The result is the date, by default in the format dd Mmm yyyy, e.g.
  793. 27 Aug 1982 (with no leading zero on the day). Alternative formats may
  794. be obtained by supplying an option parameter, of which only the first
  795. character is significant (as usual).  Possible formats are:
  796.  
  797. Base    - the theoretical number of days in the common era (i.e. since
  798.           1/1/1 AD).  On 1/1/1900 the result would be 693595.
  799. Century - the number of days so far this century (so on 1/1/1900 the
  800.           result would be 1)
  801. Days    - the number of days so far in this year (so on 12 Jan 86 the
  802.           result would be 12)
  803. European- the date in the format dd/mm/yy
  804. Julian  - the date in the format yyddd (where ddd is as in "Days" above)
  805. Month   - the full name of the current month, e.g. August
  806. Normal  - the same format as for no parameter, described above
  807. Ordered - the date in the format yy/mm/dd
  808. Standard- the date in the format yyyymmdd
  809. USA     - the date in the format mm/dd/yy
  810. Weekday - the full name of the current day, e.g. Tuesday
  811.  
  812. On the first call to DATE or TIME in an expression, a time stamp is made
  813. which is then used for all calls to these functions within that
  814. expression. Hence if multiple calls to these functions are made within
  815. a single expression, they are guaranteed to be consistent with each
  816. other.
  817.  
  818. NOTE: The date function will cease to work in the year 2000.
  819.  
  820. DELSTR(string,position[,length])
  821.  
  822. A substring of string is deleted and the result returned. The substring
  823. to be deleted starts at the given position and has length length. If
  824. the length is not specified, then the rest of the string is deleted.
  825. If the given position is greater than the length of the string, or if
  826. length is zero, then the string is returned unchanged.
  827.  
  828. DELWORD(string,position[,count])
  829.  
  830. This function is a word-oriented version of DELSTR. It deletes the
  831. substring of string which starts at the "position"th blank-delimited
  832. word and is of "count" blank-delimited words. If there are not
  833. "position" words in the string, or if count is 0, the string is
  834. returned unchanged. The string deleted includes any blanks following
  835. the final word deleted, but does not remove any blanks preceding the
  836. first word deleted.
  837.  
  838. DIGITS()
  839.  
  840. The result is the current setting of NUMERIC DIGITS.
  841.  
  842. ERRORTEXT(i)
  843.  
  844. i must be a whole number. The result is the message that would be
  845. displayed if error i were to occur, except that it does not include
  846. information such as the name of an undefined label, etc.. If error i is
  847. not defined, then an empty string is returned.
  848.  
  849. Standard Unix I/O errors may be retrieved with this function also.
  850. Just add 100 to the error number.
  851.  
  852. See the section on error messages.
  853.  
  854. FDOPEN(fd [,[mode] [,file]])
  855.  
  856. Open a file descriptor for reading or writing. See the section on the
  857. REXX I/O model.
  858.  
  859. FILENO(file)
  860.  
  861. Gives the fd number associated with a file. See the section on the REXX
  862. I/O model.
  863.  
  864. FORM()
  865.  
  866. The result is either "SCIENTIFIC" or "ENGINEERING", according to the
  867. current setting of NUMERIC FORM.
  868.  
  869. FORMAT(number [,[before] [,[after] [,[expp] [,expt]]]] )
  870.  
  871. The given number is rounded and formatted according to the information
  872. given, as described below (note that the number is always rounded
  873. according to NUMERIC DIGITS, if necessary, before being processed by
  874. this function):
  875.  
  876. If just `number' is specified, then it is formatted according to the
  877. usual rules for REXX numerics.
  878.  
  879. The number is formatted, possibly in exponential form, with `before'
  880. digits before the decimal point and `after' digits after. `before' must
  881. be strictly positive and includes any leading minus sign. `after' must
  882. be non-negative. If `after' is zero, then there will be no decimal
  883. point in the output. If either `before' or `after' is omitted, then
  884. as many places as required are used. If `before' is too small then an
  885. error results. If it is too large, then leading spaces are used to fill
  886. the extra places. The number is rounded or extended with zeros as
  887. necessary in order to have `after' digits after the decimal point
  888. (note that this is not the same as TRUNC, which truncates the number
  889. rather than rounding it). The rounding rules are as usual - the first
  890. digit which is not required is checked and if it is 5 or more, the last
  891. required digit is incremented.
  892.  
  893. `expt' specifies the trigger for exponential form. Exponential form is
  894. used whenever the number would otherwise require more than `expt'
  895. digits before or more than twice `expt' digits after the decimal point.
  896. If `expt' is zero, exponential form is always used. The number will be
  897. formatted according to NUMERIC FORM, and may need up to three places
  898. before the decimal point if ENGINEERING form is in effect. The default
  899. value for `expt' is the current setting of NUMERIC DIGITS.
  900.  
  901. `expp' specifies the number of digits (excluding the letter E and the
  902. sign) used for the exponent. If it is zero, exponential form is never
  903. used (this overrides the setting of `expt' if necessary). Otherwise, if
  904. exponential form needs to be used, the exponent must fit in the specified
  905. width, or an error results. Leading zeros are added as necessary to make
  906. the exponent the correct width. A zero exponent, however, always causes
  907. `expp+2' spaces to be added instead of the exponent (but no spaces if
  908. expp is omitted, or is zero). If `expp' is omitted, then as many places
  909. as required are used for the exponent.
  910.  
  911. Examples: (with NUMERIC FORM SCIENTIFIC and NUMERIC DIGITS 9)
  912.  
  913. format('3',4)             == '   3'
  914. format('1.73',4,0)        == '   2'
  915. format('1.73',4,3)        == '   1.730'
  916. format('-.76',4,1)        == '  -0.8'
  917. format('0.000')           == '0'
  918. format('12345.73',,,2,2)  == '1.234573E+04'
  919. format('12345.73',,3,,0)  == '1.235E+4'
  920. format('1.2345',,3,2,0)   == '1.235    '
  921. format('1234567e5',,3,0)  == '123456700000.000'
  922.  
  923. FTELL(file)
  924.  
  925. Gives the current pointer position of a file. See the section on the
  926. REXX I/O model.
  927.  
  928. FUZZ()
  929.  
  930. The result is the current setting of NUMERIC FUZZ.
  931.  
  932. INSERT(new,target[,[n][,[length][,pad]]])
  933.  
  934. The new string is inserted into the target string after the nth character
  935. or if n is omitted or is zero, the new string is inserted before the
  936. beginning of the target string. If length is specified, then the new
  937. string is padded or truncated to that length before inserting. The
  938. default pad character is a blank.
  939.  
  940. JUSTIFY(s,length[,pad])
  941.  
  942. This function first removes all surplus space from s (as per SPACE(s) ),
  943. then attempts to right-justify s in a string of "length" characters by
  944. adding spaces between the words of s. If s does not fit in a field of
  945. "length" characters, the first "length" characters of s are returned.
  946. If the optional pad character is supplied, then the words in the output
  947. string are separated by instances of that character rather than by
  948. spaces.
  949.  
  950. LASTPOS(needle,haystack[,position])
  951.  
  952. This function finds the last occurrence, if any, of the needle within
  953. haystack. The answer is the position of the last occurrence if there is
  954. one (numbering from 1 to the length of haystack), or zero if needle does
  955. not occur in haystack. If the optional position is supplied, the search
  956. starts from this position instead of the end of haystack.  If the
  957. needle is the empty string, zero is returned.
  958.  
  959. LEFT(string,length[,pad])
  960.  
  961. The first two mandatory parameters are a string and a length. The result
  962. of this function is the leftmost "length" characters of string. If
  963. string has fewer than this many characters, then it is padded up to the
  964. required length with spaces on the right, or, if the pad character is
  965. given, with this character.
  966.  
  967. Examples: left("12345",2) = "12"   left("123",5,"0") = "12300"
  968.  
  969. LENGTH(string)
  970.  
  971. The result is the number of characters in string.
  972.  
  973. LINEIN([file] [,[line] [,count]])
  974.  
  975. Inputs a line from a file. See the section on the REXX I/O model.
  976.  
  977. LINEOUT([file] [,[string] [,line]])
  978.  
  979. Outputs a line to a file. See the section on the REXX I/O model.
  980.  
  981. LINES([file])
  982.  
  983. Determines whether lines can be read from a file. See the section on the
  984. REXX I/O model.
  985.  
  986. LINESIZE()
  987.  
  988. The function attempts to find out the terminal width using a TIOCGWINSZ
  989. ioctl on the terminal, and returns the answer. If the ioctl returns an
  990. error (for instance because there is no controlling terminal), then
  991. zero is returned.
  992.  
  993. MAX(number[,number...])
  994.  
  995. This function returns the maximum of a non-empty list of numbers.
  996.  
  997. MIN(number[,number...])
  998.  
  999. This function returns the minimum of a non-empty list of numbers.
  1000.  
  1001. OPEN(path [,[mode] [,file]])
  1002.  
  1003. Opens a file for reading and/or writing. See the section on the REXX I/O
  1004. model.
  1005.  
  1006. OVERLAY(new,target[,[position][,[length][,pad]]])
  1007.  
  1008. The new string is padded or truncated to the given length and overlaid
  1009. on to the target string starting at the given position.  The default
  1010. position is 1, that is, the start of the target string.
  1011.  
  1012. PCLOSE(file)
  1013.  
  1014. Closes a file which was opened by POPEN. See the section on the REXX I/O
  1015. model.
  1016.  
  1017. POPEN(command [,[mode] [,file]])
  1018.  
  1019. Opens a pipe to a shell command. See the section on the REXX I/O model.
  1020.  
  1021. POS(needle,haystack[,position])
  1022.  
  1023. This function finds the first occurrence, if any, of needle within
  1024. haystack. The answer is the position of the occurrence if there is one
  1025. (starting from 1) or zero if needle does not occur in haystack. If the
  1026. optional position is supplied, the search starts from this position
  1027. instead of 1.  If the needle is the null string, zero is returned.
  1028.  
  1029. QUEUED()
  1030.  
  1031. This function returns the number of entries on the REXX stack.
  1032.  
  1033. RANDOM([min][,[max][,seed]])
  1034.  
  1035. A pseudo-random number is returned. If no arguments are supplied, the
  1036. number will be between 0 and 999 (inclusive). If one argument is supplied
  1037. then the result will be between 0 and that number. If both min and max
  1038. are given, then the result will be between min and max inclusive.
  1039. min must be no greater than max and the magnitude of the range (that is,
  1040. max - min) must not exceed 100000.  min, max and seed must be whole
  1041. numbers if they are specified.
  1042.  
  1043. Usually the third argument (the seed) is not supplied. In this case, on
  1044. the first call to this function the random number generator is seeded
  1045. from the system clock, and the seed is not affected on further calls, so
  1046. that a `good' sequence of random numbers is obtained.
  1047.  
  1048. The seed may be set to a specific value on each call by supplying the
  1049. third argument. To gain a predictable sequence of random numbers, the
  1050. seed is specified on the first call but not on subsequent calls.
  1051.  
  1052. REVERSE(string)
  1053.  
  1054. The function returns the reverse of string.
  1055.  
  1056. RIGHT(string,length[,pad])
  1057.  
  1058. In a similar manner to LEFT, this function returns the rightmost
  1059. "length" characters of string. If the string is too short then it is
  1060. padded on the left with spaces, or with the pad character if this is
  1061. supplied.
  1062.  
  1063. SOURCELINE([i])
  1064.  
  1065. If i is omitted, then the result is the number of lines in the program.
  1066. Otherwise, i must be an integer between 1 and sourceline() and the result
  1067. is the ith program line.
  1068.  
  1069. SPACE(s[,[count][,pad]])
  1070.  
  1071. This function formats the blank-delimited words of s with "count" pad
  1072. characters between each word and with no leading or trailing blanks.
  1073. The default for "count" is 1, and the default pad character is a space.
  1074. If "count" is 0 then all blanks are removed.
  1075.  
  1076. STREAM(stream[,[option][,command]])
  1077.  
  1078. This function examines or executes a command upon a stream.  See the
  1079. section on the REXX I/O model for more information.
  1080.  
  1081. STRIP(string[,[option][,char]])
  1082.  
  1083. Up to three parameters may be supplied. The first is a string upon which
  1084. the operation is performed - this normally consists of stripping leading
  1085. and trailing spaces. The second parameter, if supplied, must start with
  1086. one of the letters "L", "T" or "B". This means strip leading spaces,
  1087. trailing spaces, or both, respectively. The third parameter, if
  1088. supplied, must be a single character, in which case this character is
  1089. stripped instead of spaces.
  1090.  
  1091. Example: strip("000123450","l","0") = "123450"
  1092.  
  1093. SUBSTR(string,position[,length[,pad]])
  1094.  
  1095. This function makes a substring of string. Usually the parameters
  1096. string, position and length are supplied and the result is the
  1097. substring of string of length "length" starting at the "position"th
  1098. character - so
  1099.    substr("abcdefg",3,2) = "cd".
  1100. If the length is omitted, then the substring continues to the end of the
  1101. string - so
  1102.    substr("abcdefg",4) = "defg".
  1103. If part of the substring requested is outside of string, then spaces are
  1104. added - or if the parameter pad is given, this character is used to pad
  1105. the result. Thus
  1106.    substr("abc",2,4,"0") = "bc00" and substr("abc",-1) = "  abc".
  1107.  
  1108. LOCAL: REXX/imc allows the position to be a negative whole number.
  1109.  
  1110. SUBWORD(string,position[,count])
  1111.  
  1112. A substring of the given string is returned, starting at the
  1113. "position"th blank-delimited word, and of length "count" words. If
  1114. "count" is not specified, then the rest of the string, starting at the
  1115. "position"th word, is returned. The result never contains leading or
  1116. trailing blanks, but it contains all spaces between the words extracted.
  1117.  
  1118. SYMBOL(name)
  1119.  
  1120. The argument is interpreted as a symbol (or a number); it is uppercased,
  1121. and if it is a compound symbol, any simple symbol components of the tail
  1122. are substituted in as with the VALUE function. The result is the three
  1123. character string "BAD", indicating that the name is not a valid symbol,
  1124. "VAR", indicating that the name is a variable (i.e. a symbol which has
  1125. been assigned a value), or "LIT", indicating that the name is either a
  1126. constant symbol or a symbol without a value.  For example, the program:
  1127.    b='*'; a.b=5
  1128.    say symbol('a') symbol('b') symbol('a.B') symbol(A.b)
  1129.    say symbol('a.*') symbol('b.a') symbol('b.*')
  1130. would say "LIT VAR VAR LIT" and "BAD LIT BAD".
  1131.  
  1132. TIME([option])
  1133.  
  1134. The result is the time, by default in the format hh:mm:ss (in 24 hour
  1135. clock). Alternative formats may be obtained by supplying an option
  1136. parameter.  Possible formats are:
  1137.  
  1138. Civil   - hh:mmxx where hh is the hour in 12-hour notation (no leading
  1139.           zeros), mm is the minute, and xx is either am or pm.
  1140. Normal  - the same format as for no parameter, described above
  1141. Long    - hh:mm:ss.uuuuuu where uuuuuu is the number of microseconds
  1142. Hours   - the number of hours since midnight
  1143. Minutes - the number of minutes since midnight
  1144. Seconds - the number of seconds since midnight
  1145. Elapsed - On the first call the result is 0 and on subsequent calls
  1146.           the result is the elapsed time since then in the format
  1147.           mmmmm.uuuuuu (no leading zeros)
  1148. Reset   - same as Elapsed, but after the time is calculated, the timer
  1149.           is reset to zero.
  1150.  
  1151. On the first call to TIME or DATE in an expression, a time stamp is made
  1152. which is then used for all calls to these functions within that
  1153. expression. Hence if multiple calls to these functions are made within
  1154. a single expression, they are guaranteed to be consistent with each
  1155. other. Note that this means that:
  1156.  
  1157.         say time(e) sleep(2) time(e) x
  1158.         exit
  1159.   sleep:'sleep' arg(1)
  1160.         x=time(e)
  1161.         return ""
  1162.  
  1163. will type "0 0 2.374357" (perhaps) even though over  two seconds elapse
  1164. during evaluation of sleep(2).  Also, the timestamp only applies to
  1165. time() calls within a single expression, so the line "x=time(e)" is not
  1166. affected by the timestamp.
  1167.  
  1168. The elapsed time counter is saved across function calls. This means that
  1169. although a procedure inherits the elapsed time counter from its caller,
  1170. but if it should reset the clock, this does not affect any timing which
  1171. may be in progress by the caller.
  1172.  
  1173. NOTE: The time is subject to the accuracy of the system clock, which
  1174.       may not give a very reliable number of microseconds.
  1175.  
  1176. TRACE([setting])
  1177.  
  1178. The result is the current trace setting, consisting of one upper case
  1179. letter, possibly preceded by a single question mark. If the setting
  1180. is supplied as a parameter, then this is used as a trace setting for
  1181. all further execution. See the TRACE command for details.
  1182.  
  1183. TRANSLATE(string[,[tableo][,[tablei][,pad]]])
  1184.  
  1185. This function translates characters in string to other characters, or
  1186. may be used to change the order of characters in a string.
  1187. If neither translate table is specified, then the string is translated
  1188. into uppercase. Otherwise each character of string which is found in
  1189. tablei is translated into the corresponding character in tableo -
  1190. characters which are not found in tablei remain unchanged. The default
  1191. input table is XRANGE('00'x,'ff'x) and the default output table is the
  1192. null string. The output table is padded or truncated in order to make
  1193. it the same length as the input table, the default pad character being
  1194. a blank.
  1195. Examples:
  1196.    translate('abc123DEF')              == 'ABC123DEF'
  1197.    translate('abbc','&','b')           == 'a&&c'
  1198.    translate('abcdef','12','ec')       == 'ab2d1f'
  1199.    translate('abcdef','12','abcd','.') == '12..ef'
  1200.    translate('4123','abcd','1234')     == 'dabc'
  1201.  
  1202. TRUNC(number[,length])
  1203.  
  1204. The number is rounded as necessary according to NUMERIC DIGITS, and then
  1205. truncated or padded so that the result has exactly "length" digits
  1206. after the decimal point. If the length is zero or is omitted, then the
  1207. result is an integer with no decimal point. The result will never be in
  1208. exponential form.
  1209.  
  1210. Examples:
  1211.    trunc(12.6)      == 12
  1212.    trunc(345e-2,1)  == 3.4
  1213.    trunc(26,5)      == 26.00000
  1214.  
  1215. VALUE(s[,[newvalue][,selector]])
  1216.  
  1217. s is treated as a symbol, and if it has a value, that value is returned.
  1218. If s is not a valid symbol then an error results. Otherwise the result
  1219. is just as for a symbol appearing in a program. For compound symbols,
  1220. substitution occurs as normal, except that string constants and
  1221. expressions (types 4 and 5 in the description of symbols above) are not
  1222. allowed.
  1223.  
  1224. If the newvalue parameter is provided, then this value is assigned to
  1225. the symbol described above.  The symbol's old value will be returned.
  1226.  
  1227. If the selector is provided, then this indicates an alternative
  1228. variable pool to use instead of the REXX variable pool (except that the
  1229. word "REXX" is accepted as a valid name for the usual REXX variable
  1230. pool).  The only selector recognised by REXX/imc is the word
  1231. "ENVIRONMENT", which allows the value() function to examine and alter
  1232. environment variables.  Note that the names and values of environment
  1233. variables may not contain NUL characters.
  1234.  
  1235. Example: the following program
  1236.  
  1237.    a=1; b='*'
  1238.    c.a=1; c.b=2
  1239.    say value("a") value("c.a") value("c.b") value("d.b",6)
  1240.    say value("d.*")
  1241.    
  1242. will output "1 1 2 D.*" then give an error, because "*" is not allowed
  1243. as a component of a symbol (however "b" is, even if b="*").  The value
  1244. of d.b after executing these lines will be 6.
  1245.  
  1246. The instructions
  1247.  
  1248.    a=value("FOO","ENVIRONMENT")
  1249.    call value "FOO","bar","ENVIRONMENT"
  1250.  
  1251. are similar to the instructions
  1252.  
  1253.    a=getenv("FOO")
  1254.    call putenv "FOO=bar"
  1255.  
  1256. respectively.
  1257.  
  1258. VERIFY(string,reference[,[option][,position]])
  1259.  
  1260. This verifies that the string contains only characters from reference
  1261. and returns 0 if this is true. Otherwise the result is the position of
  1262. the first character in string which is not in reference.
  1263.    If the option is specified, its first letter must be either 'N'
  1264. (nomatch) or 'M' (match).  The action for 'N' is as described above.
  1265. If 'M' is specified then the result is the position of the first
  1266. character which matches a character from the reference, and 0 if no
  1267. character from reference was found in the string.
  1268.    If the position is given, the verification starts from this position
  1269. in the string instead of from the beginning.
  1270.  
  1271. Examples:
  1272.    verify('123','1234567890')           = 0
  1273.    verify('1Z3','1234567890')           = 2
  1274.    verify('AB4T','1234567890','M')      = 3
  1275.    verify('1P3Q4','1234567890',,3)      = 4
  1276.  
  1277. WORD(string,position)
  1278.  
  1279. This function returns the "position"th blank-delimited word in string,
  1280. and is identical to SUBWORD(string,position,1). If there are not
  1281. "position" words in string then the empty string is returned.
  1282.  
  1283. WORDINDEX(string,position)
  1284.  
  1285. This function returns the character position of the "position"th
  1286. blank-delimited word in string, or 0 if there are not that many words
  1287. in string.
  1288.  
  1289. WORDLENGTH(string,position)
  1290.  
  1291. This function returns the length of the "position"th blank-delimited
  1292. word in string, and is identical to LENGTH(WORD(string,position)). If
  1293. there are not that many words in string then 0 is returned.
  1294.  
  1295. WORDPOS(phrase,string[,position])
  1296.  
  1297. This is a word-oriented version of POS. It returns the word number of
  1298. the first occurrence of the phrase in the string. If "position" is
  1299. specified, the the search starts at the specified word number instead
  1300. of the beginning.  If phrase contains no words, then 0 is returned.
  1301.    phrase is a sequence of blank-delimited words which must be present
  1302. in sequence in the string and match exactly, except that multiple
  1303. blanks between words are treated as single blanks, and leading and
  1304. trailing blanks are ignored.
  1305.    This function replaces the FIND function from VMREXX.
  1306.  
  1307. WORDS(string)
  1308.  
  1309. This function returns the number of blank-delimited words in the string.
  1310.  
  1311. XRANGE([a[,b]])
  1312.  
  1313. This function returns a range of ascii characters in a string. If they
  1314. are supplied, a and b must be single characters. The defualt values for
  1315. a and b are '00'x and 'ff'x respectively. The result is a string
  1316. consisting of ascii characters in sequence starting with a and ending
  1317. with b. If a>b then a string of (b-a+257) characters is returned,
  1318. starting at a and ending at b, wrapping around from 'ff'x to '00'x.
  1319.  
  1320. UNIX Specific Functions:
  1321.  
  1322. The following functions are built into this version of REXX, although
  1323. they are not standard REXX functions. Most of these functions appear in
  1324. the literature.
  1325.  
  1326. NOTE: many of these functions which accept string arguments will ignore
  1327.       any characters after (and including) a "00"x character.
  1328.  
  1329. CHDIR(directory)
  1330.  
  1331. This function attempts to change to the named directory, and returns an
  1332. error code. The code is zero if no error occurred, otherwise the message
  1333. corresponding to the code can be obtained with the ERRORTEXT function
  1334. by first adding 100 to the number.
  1335.  
  1336. GETCWD()
  1337.  
  1338. The current working directory name is returned. If an error occurs while
  1339. attempting to name the current directory then an error message is
  1340. returned instead. The first character of the result is a `/' if and only
  1341. if no error occurred.
  1342.  
  1343. GETENV(name)
  1344.  
  1345. If the current environment contains the named variable, then its value is
  1346. returned. Otherwise an empty string is returned.
  1347.  
  1348. This call is equivalent to VALUE(name,,"ENVIRONMENT"), and it may be
  1349. deleted in a future release.
  1350.  
  1351. PUTENV(string)
  1352.  
  1353. The string must be of the form "variable=value". The specified
  1354. environment variable is set to the given value and zero is returned.
  1355. If an error occurs then 1 is returned.
  1356.  
  1357. This call is similar to VALUE(variable,value,"ENVIRONMENT"), and it may
  1358. be deleted in a future release.
  1359.  
  1360. SYSTEM(s)
  1361.  
  1362. This function takes the string s, passes it to a bourne shell, and
  1363. returns as a result all text produced by that shell command on the
  1364. standard output. This function has a side effect, namely that the
  1365. variable `rc' is set to the exit status of the shell, or -1 if the shell
  1366. couldn't be invoked for some reason.  This may in turn cause the
  1367. condition "ERROR" or "FAILURE" to be trapped (see the SIGNAL ON and
  1368. CALL ON instructions).  Except in the case that a "SIGNAL" occurs,
  1369. there will always be a result whatever the return code, but it may be
  1370. the null string if an error occurred (or if the command produced no
  1371. output).
  1372.  
  1373. USERID()
  1374.  
  1375. The result is the login-name corresponding to the owner of the
  1376. interpreter process. If that cannot be determined for some reason, an
  1377. empty string is returned.
  1378.  
  1379. Mathematical Functions
  1380.  
  1381. The following functions are treated as built-in functions, although
  1382. they are usually calculated by an external program (supplied with REXX).
  1383. In this version, all calls to these functions are directed to
  1384. /mclab/imc/sun{3|4}/rxmathfn. This is usually an executable, but a REXX
  1385. program is also provided as an alternative. Whichever is found by the
  1386. interpreter will be used.
  1387.  
  1388. All the functions described below give results according to the current
  1389. setting of NUMERIC DIGITS, but they use floating-point maths so a
  1390. maximum of about 16 digits of accuracy may be obtained. The exception is
  1391. the square root function, which can always give the required number of
  1392. digits of accuracy (subject to machine resources).
  1393.  
  1394. ACOS(x)      the arc-cosine of x in radians (0<=acos(x)<=pi)
  1395. ASIN(x)      the arc-sine of x in radians (-pi/2<=asin(x)<=pi/2)
  1396. ATAN(x)      the arc-tangent of x in radians (-pi/2<=atan(x)<=pi/2)
  1397. COS(x)       the cosine of x radians
  1398. EXP(x)       the exponential of x (2.718281... to the power x)
  1399. LN(x)        the natural logarithm of x (x>0)
  1400. SIN(x)       the sine of x radians
  1401. SQRT(x)      the square root of x (x>=0) [arbitrary precision possible]
  1402. TAN(x)       the tangent of x radians (x <> pi/2)
  1403. TOPOWER(x,y) x to the power y (like x**y except non-integer values of y
  1404.              are allowed). If y=0 then the result is 1. If x=0 and y>0
  1405.              then the result is 0. Otherwise the result is exp(y*ln(x)).
  1406. _________________________________________________________________________
  1407.  
  1408. Instructions
  1409.  
  1410. Comments are supported, and may appear anywhere that a space can, with
  1411. the exception that comments are not allowed within a multi-character
  1412. operator (e.g. ** or ==).  They can occupy any number of lines and may
  1413. be nested. 
  1414. /* This is a comment. It is started by /* and ended by */.  */
  1415.  
  1416. The star and slash characters of the comment delimiters must not be
  1417. separated by whitespace.
  1418.  
  1419. Each command must usually appear all on one line. The exception to this
  1420. rule is when a line ends with a comma. In this instance, the comma is
  1421. deleted and the next line appended with a space. Multiple lines may be
  1422. appended in this way. Thus
  1423.    say,          /* spaces and/or comments may follow the comma */
  1424.    "this is",
  1425.    "a test"
  1426. will actually be interpreted as
  1427.    say "this is" "a test"
  1428. and will result in
  1429.    this is a test
  1430.  
  1431. Note that quotation marks must always be closed before the end of a line.
  1432. For example, the following will cause an error:
  1433.    say "this is,
  1434.    a test"
  1435.  
  1436. Instructions may be separated by semicolons or by the ends of lines.
  1437.  
  1438. The following REXX commands are currently implemented. They are displayed
  1439. in upper case, but may be typed in mixed case.
  1440.  
  1441. Square brackets indicate optional parts of constructions.
  1442. _________________________________________________________________________
  1443.  
  1444. NOP
  1445.  
  1446. This does nothing. It is provided for situations such as
  1447. IF xxxx THEN NOP ELSE yyyy.
  1448. _________________________________________________________________________
  1449.  
  1450. SAY [expression]
  1451.  
  1452. The expression is evaluated and displayed on the standard output,
  1453. followed by a newline character. If no expression is supplied then just
  1454. the newline character is output.
  1455.  
  1456. LOCAL: The command:  SAYN expression
  1457.        evaluates the expression and displays it without a newline
  1458.        character.  Note that a similar effect can be obtained with
  1459.        the function call charout, though the output may have to be
  1460.        flushed by calling charout a second time with no parameters.
  1461. _________________________________________________________________________
  1462.  
  1463. symbol=value
  1464.  
  1465. If `symbol' is a simple or compound symbol then it is assigned the value
  1466. `value', so that assignment in REXX has the usual meaning. A compound
  1467. symbol is subject to the usual substitution of qualifiers.
  1468.  
  1469. If `symbol' is a stem, then all possible compound symbols which start
  1470. with the given stem are assigned the value `value'.
  1471.  
  1472. Variables are allowed to have the same names as REXX keywords, with the
  1473. exception of some keywords within particular commands (e.g. "until" in a
  1474. DO construction). The following rule is applied, in order to distinguish
  1475. between an assignment and any other command: if the first word in the
  1476. line is followed by an `=' (after optional spaces), then it is an
  1477. assignment. This does not apply, however, to constant symbols, which can
  1478. not be assigned to.
  1479. _________________________________________________________________________
  1480.  
  1481. DROP symbol [symbol,...]
  1482.  
  1483. The DROP command un-assigns each symbol named after the DROP keyword.
  1484. Simple or compound symbols or stems may be dropped. If the symbol is a
  1485. stem, then all compound symbols starting with that stem are dropped.
  1486.  
  1487. If a variable has been passed to a procedure with the PROCEDURE EXPOSE
  1488. construction, then the variable in the calling procedure will be dropped
  1489. also. If a dropped symbol is subsequently assigned a value, then the
  1490. variable will also be assigned that value in the calling procedure.
  1491.  
  1492. It is not an error to DROP a non-existent symbol, or to DROP a symbol
  1493. twice.
  1494.  
  1495. NOTE: Even if a compound variable is dropped, its value will always be
  1496.       undefined immediately after the drop.  For example,
  1497.          stem.="Some value"
  1498.      drop stem.6
  1499.      say stem.5 stem.6 stem.7
  1500.       makes stem.6 undefined and says "Some value STEM.6 Some value".
  1501. _________________________________________________________________________
  1502.  
  1503. EXIT [expression]
  1504.  
  1505. The EXIT instruction returns control from a program to its most recent
  1506. external caller. This will either be a rexx external call (that is,
  1507. `CALL name' or `name()' where name is the name of the REXX program rather
  1508. than an internal or builtin function name) or a UNIX command, if the
  1509. program was not called by another REXX program. All the current DO,
  1510. SELECT, INTERPRET and internal call structures are terminated, and
  1511. control resumes at the point of the most recent external call. An
  1512. expression may follow the EXIT statement; this is passed back to the
  1513. caller in the same way as in the RETURN statement. If control is returned
  1514. back to UNIX, then the expression must be an integer if it is supplied,
  1515. and it is used as the exit value of the interpreter. If no value is
  1516. supplied then the exit code will be zero.
  1517.  
  1518. Note that reching the end of a program is the same as executing "EXIT".
  1519. In other words, reaching the end of a program terminates all internal
  1520. function calls.
  1521. _________________________________________________________________________
  1522.  
  1523. NUMERIC DIGITS n
  1524. NUMERIC FUZZ n
  1525. NUMERIC FORM   SCIENTIFIC
  1526.              | ENGINEERING
  1527.          | "string constant"
  1528.              | [VALUE] expression
  1529.  
  1530. The expression evaluator uses arbitrary length arithmetic for numeric
  1531. operations. The precision to which operations are carried out by the
  1532. evaluator may be altered using the NUMERIC DIGITS command, and is
  1533. initially 9. The number supplied will be the number of digits kept after
  1534. each operation, not including the decimal point, or leading zeros, which
  1535. are dropped by all arithmetic operations. The upper limit for NUMERIC
  1536. DIGITS is about 10000 (defined in const.h).  Note that a single
  1537. multiplication or division can take many minutes at this precision.
  1538.  
  1539. NUMERIC FUZZ is initially zero and is set to zero by each NUMERIC DIGITS
  1540. command. It specifies a temporary reduction in the precision of
  1541. arithmetic when doing comparisons (remember, for all numeric comparisons,
  1542. the two operands are subtracted and the result is compared with zero. It
  1543. is the precision of the subtraction which is affected by NUMERIC FUZZ).
  1544. The upper limit for NUMERIC FUZZ is clearly one less than the current
  1545. value of NUMERIC DIGITS.
  1546.  
  1547. NUMERIC FORM is used to set the form of exponents to either `scientific'
  1548. mode or `engineering' mode. When an exponent is used, in the scientific
  1549. mode there is always precisely one digit, which is non-zero, before the
  1550. decimal point. In engineering mode, there are up to three digits before
  1551. the decimal point, and the exponent is always a multiple of three.
  1552.    If an expression is used, it must evaluate to "SCIENTIFIC" or
  1553. "ENGINEERING" in upper case. If the expression does not start with a
  1554. symbol or string constant, then the keyword VALUE may be omitted.
  1555.  
  1556. The NUMERIC settings are saved across function calls, and restored on
  1557. return from a function, so a function may set the precision, etc. that
  1558. it needs without affecting the caller.  Moreover, the settings will be
  1559. restored to their default settings just after entering any external
  1560. REXX procedure.
  1561. _________________________________________________________________________
  1562.  
  1563. DO
  1564.  
  1565. There are two uses of DO:
  1566.  
  1567. 1.  DO
  1568.     ...commands...
  1569.     END
  1570.  
  1571.   This is a compound statement, i.e. the DO and END are wrapped around
  1572.   the block of commands so that they appear like one statement and may
  1573.   be used in IF constructs.
  1574.  
  1575. 2.  DO [ symbol=start  [TO  finish]  ]     [WHILE expression_w]
  1576.        [               [BY  step  ]  ]
  1577.        [               [FOR count ]  ]     [UNTIL expression_u]
  1578.  
  1579.        [ expression_c                ]
  1580.        [FOREVER                      ]
  1581.  
  1582.     ...commands...
  1583.     
  1584.     END [symbol]
  1585.  
  1586.     where start, finish, step, count and the expressions are numerical
  1587.     expressions. Expression_c and count are required to be non-negative
  1588.     integers.
  1589.  
  1590.   This is a repetitive command. If `symbol' is present in the DO
  1591.   statement, then:
  1592.  
  1593.     a. `symbol' may be any simple or compound symbol
  1594.     b. the symbol name may appear after the END statement; if it does,
  1595.        then it must be the same one as after the DO.  The DO symbol and
  1596.        the END symbol are compared literally, without substituting any
  1597.        components in the tail of a compound symbol, but the comparison
  1598.        is case insensitive.
  1599.     c. the value of start is assigned to the symbol before the loop is
  1600.        entered.
  1601.     d. if [TO finish] is present, then the loop is not executed after the
  1602.        control variable (named by the symbol) passes the finish value.
  1603.        If it is not present, then the loop may potentially be executed
  1604.        for ever (unless a FOR clause is present).
  1605.     e. if [BY step] is present, then the variable is incremented by step
  1606.        after each pass. Otherwise the variable is incremented by 1.
  1607.     f. If [FOR count] is present, then the loop is executed at most
  1608.        count times.
  1609.     g. The TO, FOR and BY clauses may be specified in any order. (Note:
  1610.        each should be specified at most once, but specifying one or more
  1611.        of these twice will not cause an error. The last one encountered
  1612.        is the one which is used).
  1613.   If `symbol' is not present, then nothing must follow the END.
  1614.  
  1615.   If the expression_c is specified, then the loop is executed this number
  1616.   of times (unless terminated by some other condition).  Note that
  1617.   expression_c must not start with a symbol followed by '=', because it
  1618.   would then be taken to be a `symbol' as above.  This may be prevented
  1619.   by enclosing the expression in parentheses.
  1620.  
  1621.   If a WHILE clause is present, then expression_w is evaluated before
  1622.   each pass and the loop is terminated if the result is false.
  1623.   
  1624.   If an UNTIL clause is present, then expression_u is evaluated after
  1625.   each pass and the loop is terminated if the result is true.
  1626.   
  1627.   A `DO FOREVER' instruction creates a loop which never terminates
  1628.   (unless a LEAVE instruction is encountered).
  1629.   
  1630.   Note that if expression_w is false or if the variable clause needs no
  1631.   repetition, or if count or expression_c is zero, then the body of the
  1632.   loop will not be executed at all.
  1633.  
  1634. An END must appear for each DO construct, and if labelled with a symbol,
  1635. must have the correct symbol.
  1636.  
  1637. NOTE: The name of any variable specified at the DO statement is
  1638.       evaluated again each time it is incremented at the end of a
  1639.       pass through the loop.  This means, for example, that in
  1640.       "DO a.i=1 TO 10", the name of the variable which is incremented
  1641.       depends on the current value of i.  (Altering the value of i is,
  1642.       of course, not highly recommended).
  1643.  
  1644. Example: The code
  1645.  
  1646.     do name=expri to exprt by exprb for exprf while exprw (or until expru)
  1647.        ... instructions ...
  1648.     end
  1649.  
  1650. will be executed as if it were written thus:
  1651.  
  1652.     $tempi = expri       /* variables staring with $ are */
  1653.     $tempt = exprt       /* invisible to the rest of the */
  1654.     $tempb = exprb       /* program. */
  1655.     $tempf = exprf
  1656.     name = $tempi + 0
  1657.  
  1658.  $loop: if name > $tempt then goto $end    /* "goto" is a pseudo-op */
  1659.         if $tempf = 0 then goto $end       /* meaning the obvious   */
  1660.     if \exprw then goto $end
  1661.  
  1662.     ... instructions ...
  1663.  
  1664.  $iter: if expru then goto $end            /* "iterate" will come here */
  1665.         name = name + $tempb
  1666.     $tempf = $tempf - 1
  1667.     goto $loop
  1668.  $end:                                       /* "leave" will come here */
  1669.  
  1670. (If any of the constructs in the original code are left out, the
  1671. coresponding lines will be left out of this example).
  1672. _________________________________________________________________________
  1673.  
  1674. LEAVE [symbol]
  1675.  
  1676. If a symbol name is not specified, then LEAVE leaves the innermost
  1677. repetitive DO statement by jumping to the statement after the END
  1678. statement for that loop. If a symbol name is specified, then LEAVE
  1679. leaves the innermost loop with that symbol as control (i.e. where the
  1680. DO statement specified that symbol) - this may involve leaving several
  1681. inner loops.  The specified symbol must match that in the DO
  1682. instruction literally, except that case is ignored.
  1683.   The LEAVE statement will not return from procedures or functions.
  1684.   If there is no suitable loop to leave within the current function or
  1685. procedure call, then an error results.
  1686.  
  1687. NOTE: LEAVE will not exit from a string being interpreted: it is an
  1688.       error to use LEAVE within INTERPRET unless the corresponding DO
  1689.       occurs there as well.
  1690. _________________________________________________________________________
  1691.  
  1692. ITERATE [symbol]
  1693.  
  1694. This instruction is similar to LEAVE, but instead of leaving the loop
  1695. it jumps to execute the END statement and possibly continue with another
  1696. iteration around the loop.  The same NOTE applies.
  1697. _________________________________________________________________________
  1698.  
  1699. IF expression [;] THEN [;] instruction [ ; ELSE [;] instruction]
  1700.  
  1701. This construction has the obvious meaning. Note that the THEN and ELSE
  1702. must be followed by single instructions, but the DO-END or SELECT-END
  1703. (qv) and even IF-THEN-ELSE constructions count as single instructions
  1704. for this purpose.
  1705.  
  1706. A semicolon or line-end may optionally appear between the expression and
  1707. the THEN, but one must appear before ELSE, as above.
  1708.  
  1709. IF statements may be nested, but note that each ELSE statement
  1710. corresponds to the most recent IF statement without an ELSE. If a null
  1711. THEN or ELSE clause is needed, the NOP instruction must be used (as a
  1712. null statement is just ignored by REXX).
  1713.  
  1714. BUG: There is at present no way to detect incorrectly positioned ELSE
  1715.      statements. If an ELSE is detected during program interpretation,
  1716.      this will just cause the interpreter to skip the following statement
  1717.      and will not be an error. This bug also prevents the interpreter
  1718.      from flagging a construction such as "if expr then else ..." since
  1719.      in that case the "else" will be considered to be the statement to
  1720.      execute when expr is true.
  1721. _________________________________________________________________________
  1722.  
  1723. SELECT [expression]
  1724.    WHEN expression THEN instruction
  1725.    WHEN expression THEN instruction
  1726.    ...
  1727.    [OTHERWISE instructions]
  1728. END [SELECT]
  1729.  
  1730. If an expression is supplied after SELECT, then this construction is like
  1731. a Pascal or Modula `CASE' construction. The expression is compared with
  1732. each of the other expressions in turn, until one is found that matches
  1733. (using the `=' form of equality). If a match is found, then the
  1734. corresponding instruction is executed. If a match is not found, then an
  1735. OTHERWISE clause must be specified, or else an error is reported. The
  1736. instructions after OTHERWISE will be executed.
  1737.   If an expression is not specified after SELECT, then the construction
  1738. is a list of guarded commands - that is, each expression is evaluated
  1739. until a true one is found, and the corresponding action is taken. Again,
  1740. if no expression is true and there is no OTHERWISE then an error is
  1741. reported.
  1742.   The word SELECT may be placed after the closing END but is optional.
  1743. Adding the word SELECT allows easier detection of missing ENDs.
  1744.   It is an error for the word WHEN or OTHERWISE to appear anywhere except
  1745. immediately inside a SELECT construction.
  1746.   Precisely one instruction is required after each WHEN, so NOP should be
  1747. used if no action is required. NOP need not be used after OTHERWISE.
  1748.   If multiple instructions are required to follow each WHEN condition,
  1749. then they should be contained in a DO ... END block.  Multiple
  1750. instructions may follow the OTHERWISE keyword.
  1751.  
  1752. LOCAL: The optional expression following the SELECT keyword, and the
  1753.        optional SELECT following the END keyword are features of PL/1
  1754.        and not of standard REXX.
  1755. _________________________________________________________________________
  1756.  
  1757. [PARSE [UPPER]] ARG template
  1758. [PARSE [UPPER]] PULL [template]
  1759. PARSE [UPPER] LINEIN [template]
  1760. PARSE [UPPER] SOURCE template
  1761. PARSE [UPPER] VERSION template
  1762. PARSE [UPPER] NUMERIC template
  1763. PARSE [UPPER] VAR symbol template
  1764. PARSE [UPPER] VALUE expression WITH template
  1765.  
  1766. This command is a powerful parser which divides the operand up as
  1767. specified by the `template'. If the UPPER keyword is specified, then the
  1768. operand is uppercased before parsing.
  1769.  
  1770. The "ARG template" and "PULL template" commands are short forms of
  1771. "PARSE UPPER ARG template" and "PARSE UPPER PULL template" respectively.
  1772.  
  1773. The possible operands are as follows:
  1774.  
  1775. ARG   - the command-line arguments, or the arguments passed by a function
  1776.         or procedure call, are parsed.
  1777. PULL  - the top value on the stack, if one exists, is parsed; otherwise
  1778.         a line of input is read from the standard input and parsed as
  1779.     described for LINEIN below.  See QUEUE/PUSH for details about
  1780.     the stack.
  1781. LINEIN- A line is read directly from stdin.  The stack is not affected
  1782.         by this instruction.  In general, PULL is recommended in
  1783.     preference to LINEIN.
  1784.  
  1785.     If a line cannot be read because of an I/O error or EOF
  1786.     condition, then the NOTREADY condition will be raised and an
  1787.     empty string will be parsed.  The NOTREADY condition is ignored
  1788.     unless trapped by SIGNAL ON or CALL ON, in which case it is
  1789.     difficult to tell the difference between an empty input line
  1790.     and an I/O error.  However, the STREAM() function may be
  1791.     used to examine the most recent I/O error on stream "stdin".
  1792.  
  1793.         NOTE: If the program is interrupted (via ^C) while input is being
  1794.               read, then the characters which have been read in may be
  1795.           lost, but the remainder of a partially-input line will
  1796.           remain to be read again.
  1797.  
  1798. SOURCE- An implementation-dependent string representing the `source' of
  1799.         the program is parsed.
  1800.         In this implementation, the string contains five words:
  1801.          1. the system under which the interpreter runs (always UNIX)
  1802.          2. the way in which the program was called (one of COMMAND,
  1803.             FUNCTION or SUBROUTINE, depending whether the program was
  1804.             invoked by a command shell or as a function or subroutine)
  1805.          3. the name of the file containing the program, with the full
  1806.             path name (unless no directory was specified and getwd could
  1807.             not name the current directory)
  1808.          4. the name by which the program was called (always without a
  1809.             path name).
  1810.      5. the environment name which was current when the program
  1811.         started up
  1812. VERSION-A string representing the version of the REXX interpreter is
  1813.         parsed. This contains five words:
  1814.          1. A word describing the language, of which the first four
  1815.             letters are always REXX. In this implementation the word is
  1816.             REXX/imc.
  1817.          2. A string representing the version number (e.g. 1.0)
  1818.          3,4,5. The date on which the interpreter was compiled, in the
  1819.             same format as the DATE() function (e.g. 18 May 1990).
  1820. NUMERIC-The current NUMERIC settings are parsed.  There are three words
  1821.         in the string to be parsed: NUMERIC DIGITS, NUMERIC FUZZ and
  1822.     NUMERIC FORM respectively.
  1823. VAR   - The symbol specified is evaluated, and if it represents
  1824.         a currently defined variable, its value is substituted. The
  1825.         result is then parsed.
  1826. VALUE - The expression between "VALUE" and "WITH" is evaluated and then
  1827.         parsed (note that WITH is a reserved keyword in this instruction)
  1828.  
  1829. If no template is supplied, the information to be parsed is collected and
  1830. then thrown away.
  1831.  
  1832. The "ARG" and "VALUE" forms may parse more than one string at once. This
  1833. comes about with "ARG" when a function or procedure call (note - not a
  1834. command line call) passes more than one argument, or with "VALUE" when
  1835. the expression contains comma separators. In this case, the parse
  1836. template may contain commas. The part of the template before the first
  1837. comma applies to the first operand string, that part between the first
  1838. and second commas applies to the second string, and so on. E.g.
  1839.  
  1840.  PARSE VALUE 43 56,5*9,hello,there WITH template1,template2,
  1841.  
  1842. Here template1 applies to "43 56"; template2 applies to "5*9" and no
  1843. other parsing takes place. Note that there does not have to be a template
  1844. for each operand string, and also that there does not have to be an
  1845. operand string for each template (in this case the extra templates will
  1846. be applied to the empty string).
  1847.  
  1848. LOCAL: Parsing multiple strings with the PARSE VALUE construction is a
  1849.        local extension.
  1850.  
  1851. A parse template obeys the following grammar. A symbol in brackets
  1852. indicates that that symbol may be optionally present. A character in
  1853. single quotes indicates that that character should be typed literally.
  1854. A symbol in double quotes is a terminal symbol, indicating the
  1855. appropriate REXX entity should be present.
  1856.  
  1857.  template        -> [firstPosition] assignments [assignments]
  1858.  assignments     -> [nextPosition] varlist [stopPosition]
  1859.  varlist         -> varname [varlist]
  1860.  varname         ->   "non-constant symbol"
  1861.                     | '.'
  1862.  firstPosition   -> position
  1863.  nextPosition    -> position [nextPosition]
  1864.  stopPosition    -> position
  1865.  position        ->   searchPosition
  1866.                     | absPosition
  1867.                     | relPosition
  1868.                     | '(' "expression" ')'
  1869.  searchPosition  -> "string constant"
  1870.  absPosition     ->   "integer"
  1871.                     | '=' numexpr
  1872.  relPosition     ->   '+' numexpr
  1873.                     | '-' numexpr
  1874.  numexpr         ->   "integer"
  1875.                     | '(' "integer expression" ')'
  1876.  
  1877. Each position symbol in this grammar indicates a column number to the
  1878. parser. Positions are translated to column numbers (numbered from 1 up to
  1879. l+1, where l is the length of the string being parsed) in the following
  1880. way. Note that the absPosition indicator "1" is implicitly present
  1881. before and after any parse template.
  1882.  
  1883. absPosition:    gives the column number directly, except that numbers not
  1884.                 between 1 and l+1 are translated into 1 or l+1 as
  1885.                 appropriate.
  1886. searchPosition: searches for the given string constant in the string
  1887.                 being parsed, starting from the most recent column number
  1888.                 Usually, two column numbers result: the column number of
  1889.                 the first character which matched, and that of the first
  1890.                 character after the matching string. The latter number is
  1891.                 suppressed if the next position indicator (if any) is a
  1892.                 `relPosition'. If the string is not found, then the
  1893.                 single column number l+1 results.
  1894. "expression":   evaluates the expression and then treats it as the string
  1895.                 constant of a searchPosition
  1896. relPosition:    The given positive or negative number is added to the
  1897.                 previous column number to give the result. As for an
  1898.                 absolute position, numbers which are out of range are
  1899.                 translated into 1 or l+1 as appropriate.
  1900.  
  1901. For example, given the string "hello, world, hello!" and the position
  1902. indicators 1 "ello" +4 ! 5 -3 'x' -2 1, the resulting column numbers
  1903. would be:
  1904.   1  (the given number)
  1905.   2  (the first character of "ello" - the second number is suppressed)
  1906.   6  (+4 characters from the previous position)
  1907.  20}{(the first character of "!")
  1908.  21}{(the first character after "!")
  1909.   5  (the given number)
  1910.   2  (-3 characters from 5)
  1911.  21  (the end of the string, since "x" is not found)
  1912.  19  (-2 characters from 21)
  1913.   1  (the given number)
  1914.  
  1915. The position indicators are translated into column numbers independent
  1916. of the varlist, except in one case described below. Thus the parse
  1917. template may be reduced by the above rules into a sequence of column
  1918. numbers and varlists. Taking into account the rule that each template is
  1919. implicitly prefixed and suffixed by the column number "1", each varlist
  1920. thus occurs between two column numbers. Each varlist is treated
  1921. separately, as follows:
  1922.  
  1923. Denote the varlist, together with the column numbers immediately before
  1924. and after the varlist, as m v1 v2 ... vk n. If m<n, or if m=n and
  1925. n resulted from a search, then there exists a well-defined substring s of
  1926. the string being parsed, which starts at column m and is of length n-m.
  1927. (this string ends at, but does not include, column n). Otherwise, let s
  1928. be that substring which starts at column m and continues to the end of
  1929. the string being parsed. Then the string s is divided between the
  1930. variables of the varlist by assigning the blank-delimited tokens to v1,
  1931. v2, ... in order. If there are more varnames in the varlist than there
  1932. are blank-delimited tokens, then the extra varnames are assigned with the
  1933. empty string. The tokens assigned to varnames v1, v2, ... , v(k-1) will
  1934. contain no leading or trailing blanks, but the token assigned to vk will
  1935. contain all blanks which occur after v(k-1), except for the one blank
  1936. immediately after v(k-1).
  1937.  
  1938. Each varname is either a symbol name or a dot. If the varname is a dot,
  1939. then the token which would be assigned to it is thrown away. Otherwise
  1940. the token is assigned to it in the usual way, just as if there had been
  1941. an instruction: symbol = token
  1942.  
  1943. NOTE: Some versions of REXX allow only a symbol name between parentheses
  1944.       where this version allows an arbitrary expression.
  1945.  
  1946. The one case in which the presence of a varlist may affect the
  1947. translation from position indicators to column numbers is when one or
  1948. more of the symbols mentioned in an "expression" is also stated in a
  1949. varlist. Hence:
  1950.  
  1951. PARSE VALUE "s/this/that" WITH 2 delim +1 first (delim) second
  1952.  
  1953. will assign "/" to delim, "this" to first and "that" to second. This is
  1954. because the variable delim is assigned as soon as the "+1" is reached.
  1955. This provides a way to provide commands (such as locate commands) which
  1956. take any string parameter and also some options. It allows any delimiter
  1957. to separate the parameter from the options.
  1958. However,
  1959.  
  1960. PARSE VALUE "s / this/that" WITH . delim first (delim) second
  1961.  
  1962. will not have the same effect, since delim and first are not assigned
  1963. until after the expression (delim) has been searched for.
  1964.  
  1965. Note that the symbols are assigned in order from left to right, so
  1966.  
  1967. PARSE VALUE "1 2 3" WITH a x.a y.a
  1968.  
  1969. will assign 1 to a, then 2 to x.1, then 3 to y.1
  1970.  
  1971. Other Examples:
  1972.  
  1973. PARSE VALUE "Hello there ! etc.." WITH a b ! . "c" c
  1974.  
  1975. will assign "Hello" to a and "there " to b, then throw away " et" and
  1976. assign ".." to c.
  1977.  
  1978. PARSE VALUE "123456789" WITH a +4 b 6 c
  1979.  
  1980. will assign "1234" to a, "5" to b, and "6789" to c.
  1981.  
  1982. PARSE VALUE "   multiple   spaces   between   words" WITH a b c
  1983.  
  1984. will assign "multiple" to a, "spaces" to b and "  between   words" to c.
  1985.  
  1986. PARSE VALUE "a  b  c  d  e  f" WITH "b" a b "e"
  1987.  
  1988. will assign "c" to a and " d  " to b.
  1989.  
  1990. PARSE VALUE "hello-there" WITH a "-" b -1 c +1
  1991.  
  1992. This assigns "hello" to a, "-there" to b and "o" to c. 
  1993. _________________________________________________________________________
  1994.  
  1995. QUEUE [expression]
  1996. PUSH  [expression]
  1997.  
  1998. These instructions place the specified single expression on to the stack.
  1999. If the expression is omitted, then the null string will be used.
  2000. If QUEUE is used, the expression will be added in FIFO order (it will be
  2001. retrieved after all currently existing stack items). If PUSH is used, the
  2002. expression will be added in LIFO order (it will be retrieved before all
  2003. currently existing stack items).
  2004.  
  2005. Other programs may communicate with the REXX stack to provide data for
  2006. or retrieve data from a REXX program. See the separate section on the
  2007. REXX stack for details.
  2008. _________________________________________________________________________
  2009.  
  2010. CALL name [arg][,[arg],...]]
  2011.  
  2012. This section covers function calls as well, because evaluating a
  2013. function is almost identical to calling a subroutine (even built-in
  2014. functions may be CALLed).  The main difference is that while a
  2015. subroutine called as a function is required to return a result, a
  2016. subroutine called with CALL is not required to do so.  Also, calling a
  2017. subroutine as a function does not cause the special variable RESULT to
  2018. be set on return.
  2019.  
  2020. The CALL command evaluates its arguments, if any, and passes them to
  2021. the named function or procedure. The procedure may or may not return a
  2022. result. If it does return a result, then this is assigned to the variable
  2023. RESULT. The only difference between a CALL to a function and a function
  2024. call (that is, between `CALL xyz args' and `xyz(args)') is that the
  2025. latter expects a result and returns that to the expression evaluator (it
  2026. is an error if the function does not return a result), whereas the former
  2027. does not expect a result, but it assigns it to RESULT if there is one.
  2028. If a called procedure does not return a result, then the variable RESULT
  2029. will be dropped - that is, it will no longer have a value.
  2030.  
  2031. As with function calls parameters may be omitted (note however that if a
  2032. line ends with a comma then that comma is treated as a continuation
  2033. character, so if the line needs to end with a 'real' comma then another
  2034. character, such as a semicolon, needs to be added after the comma).
  2035. In addition, the name may be a string constant (enclosed in quotes), in
  2036. which case, as for function calls, the internal label table is not
  2037. searched, and for external subroutines a path name may be specified.
  2038.  
  2039. The name represents the name of a function (or procedure), and these are
  2040. searched for in the following order:
  2041.  1. internal functions
  2042.  2. built-in functions
  2043.  3. external binary programs
  2044.  4. external REXX programs
  2045.  
  2046. An internal function is introduced (anywhere in the current program) by
  2047. a label, which takes the form
  2048.   name:
  2049. and may be placed anywhere at the start of a statement (or on its own on
  2050. a line). When an internal function is called, all labels are checked, and
  2051. when a match is found, interpretation jumps to the statement immediately
  2052. following the label, and continues until the next RETURN statement (or
  2053. EXIT, or the end of the program). On return execution continues from the
  2054. point of the call.
  2055.   The name may contain letters, numbers, dots and characters which are
  2056. valid in symbols, but must not start with a number or dot or end with a
  2057. dot. The name is translated to uppercase (except in the case of string
  2058. constants) but no variable substitution occurs, even after a dot.
  2059.   On entry to an internal function, the special variable SIGL will be
  2060. set to the line number of the instruction which caused the transfer of
  2061. control.  This applies equally to function calls, subroutine calls with
  2062. the CALL instruction, and instructions which cause a condition handler
  2063. to be called (see "CALL ON" below).
  2064.  
  2065. An external function consists of a file, whose name contains only
  2066. lowercase letters, numbers, dots and underlines. If the name given is a
  2067. string constant, then it may contain a path name, but if it does not or
  2068. if the name is not a string constant then the file must be in the
  2069. current directory or one of the directories named in the PATH
  2070. environment variable. The name given in the function call (or CALL
  2071. statement) is translated to lowercase (even for string constants) and
  2072. searched with ".rxfn" appended. If that file is found, then it is assumed
  2073. to be a binary file. Otherwise the default extension (see section on
  2074. invocation) is appended to the name and it is searched again, and again
  2075. if that is not found then the search is tried again with ".exec" appended
  2076. If either of these two files is found, then it is assumed to be a REXX
  2077. program. Otherwise there is an error.
  2078.  
  2079. Once an external binary function has been found, it becomes in effect
  2080. a built-in function, and translation to lower case is not performed.
  2081. When searching for such functions, the interpreter will ignore any
  2082. leading pathname specification.
  2083.  
  2084. An internal function may or may not hide (some or all of) its variables
  2085. using the PROCEDURE command, described below. An external function,
  2086. however, always has all of its variables hidden. There is therefore no
  2087. way for one REXX program to affect the variables of another, except via
  2088. parameters and results. (Note that data can be passed back and forth via
  2089. the stack, however).
  2090.  
  2091. The arguments to a function are picked up using the ARG variant of the
  2092. PARSE command above.
  2093.  
  2094. Example:
  2095.         parse arg x         /* this is an example factorial program. */
  2096.         say x"!="fact(x)
  2097.         exit
  2098.  fact:  parse arg p         /* the argument to fact is assigned to p */
  2099.         if p<3 then return p
  2100.         return p*fact(p-1)
  2101.  
  2102. An external function which is a ".rxfn" file must be linked (supply no
  2103. flags on the command line) and have magic number ZMAGIC.  Details for
  2104. writing such functions are contained in the technical reference.
  2105.  
  2106. CALL ON  condition [NAME symbol]
  2107. CALL OFF condition
  2108.  
  2109. These call instructions provide error trapping.  The possible
  2110. conditions which may be trapped are as follows:
  2111.  
  2112.  FAILURE:  A command to the environment returned a "failure" code.
  2113.            Usually this means a negative return code, but see the
  2114.        section on commands to the environment.
  2115.  ERROR:    A command to the environment returned an "error" code.
  2116.            This means a non-zero return code.  Note that if "failures"
  2117.        are not being trapped, then "error" will catch failures
  2118.        also.
  2119.  NOTREADY: A function from the REXX I/O model (see the separate section)
  2120.            was unsuccessful because, for example, an input function
  2121.        encountered an end-of-file condition.
  2122.  HALT:     The user has attempted to halt the program, for example by
  2123.            typing Control-C.  Signals SIGHUP and SIGTERM also raise the
  2124.        HALT condition.
  2125.  
  2126. (These are the same conditions as for SIGNAL ON, except that the two
  2127. conditions SYNTAX and NOVALUE may not be trapped by CALL ON).
  2128.  
  2129. The CALL ON instruction turns on condition handling.  Whenever the
  2130. specified condition occurs, a CALL is made to a handling routine.  If
  2131. the NAME keyword is specified, then the following symbol is taken as
  2132. the name of the handling routine.  Otherwise the handling routine has
  2133. the same name as the condition.  On return from the call, execution
  2134. proceeds normally.  The RESULT variable will not be affected by the
  2135. call.  During the handling routine, the condition handling will be set to
  2136. "DELAY".  For the FAILURE, ERROR and NOTREADY conditions, this means
  2137. that further conditions will be ignored until the handling routine
  2138. returns or until handling is explicitly turned on or off.  For the HALT
  2139. condition, the program will continue executing but the halt signal will
  2140. be remembered until until the handling routine returns or until
  2141. handling is explicitly turned on or off.  At that time the signal will
  2142. be handled in an appropriate way.
  2143.  
  2144. Condition handling with the CALL ON instruction always occurs at clause
  2145. boundaries.  When a condition occurs, it is delayed until the currently
  2146. executing clause has completed, and then the condition handler is
  2147. called.
  2148.  
  2149. At any time after the handling routine is called and before it returns,
  2150. the CONDITION() builtin function may be used to retrieve information
  2151. about the condition which was trapped.  The information provided by
  2152. this function is saved across function calls.  If a further condition
  2153. is handled while the handler is still active, this will not affect the
  2154. information which may be provided to the current handler.
  2155.  
  2156. When a condition handler is activated, the special variable SIGL is set
  2157. to the line number of the instruction in which the condition was
  2158. raised.  Also, for conditions ERROR and FAILURE, the special variable
  2159. RC will hold the return code of the command which caused the condition
  2160. to be raised.
  2161.  
  2162. Condition handling will always remain on until turned off with either
  2163. "CALL OFF condition" or "SIGNAL OFF condition".  If an external routine
  2164. is called, condition handling will be turned off temporarily until the
  2165. external routine finishes or turns condition handling on.
  2166.  
  2167. The status of condition handling is saved across function calls.  If a
  2168. subroutine uses a "CALL ON/OFF" or "SIGNAL ON/OFF" instruction, the
  2169. condition handling within the current routine will be unaffected.
  2170.  
  2171. A CALL OFF instructions cancels condition handling for a particular
  2172. condition.  If handling is turned off for ERROR, FAILURE or NOTREADY,
  2173. then the condition will be ignored whenever it occurs.  If handling is
  2174. turned off for HALT then the program will halt when the condition
  2175. occurs.
  2176.  
  2177. NOTE: Because calling the handling routine affects the special variable
  2178.       SIGL, this variable can no longer be trusted to remain constant
  2179.       when CALL ON HALT is in effect, since this condition can occur at
  2180.       any time without notice.
  2181. _________________________________________________________________________
  2182.  
  2183. RETURN [value]
  2184.  
  2185. This statement returns control to the most recent caller, optionally
  2186. returning a value to the caller. All current DO and SELECT structures
  2187. are exited and, if appropriate, the current variables are deleted and
  2188. the caller's variables are reinstated.
  2189.  
  2190. If the caller was a function call or a CALL statement, the value may be
  2191. any string which is passed to the caller in the manner described above.
  2192. If the caller was a function call, the return value must be given or an
  2193. error results.  On return from a condition handler, the result is
  2194. ignored.
  2195.  
  2196. If the caller was a shell (that is, no CALL statement or function call
  2197. is currently active), then the RETURN statement exits from the REXX
  2198. interpreter. The return value need not be given, but if it is specified
  2199. it must be an integer, which is returned to the shell as an exit status.
  2200. _________________________________________________________________________
  2201.  
  2202. PROCEDURE
  2203. PROCEDURE EXPOSE var1 [var2 ...]
  2204. PROCEDURE HIDE var1 [var2 ...]    (LOCAL)
  2205.  
  2206. The PROCEDURE command is used in an internal function or procedure to
  2207. hide the caller's variables.
  2208.  
  2209. The PROCEDURE command on its own hides all the caller's variables and
  2210. makes sure that on return all the current function's variables are
  2211. erased. On return from a function containing this instruction, the
  2212. caller's old variables are reinstated when the current function's have
  2213. been deleted.
  2214.  
  2215. The PROCEDURE EXPOSE varlist command is like the form with no arguments
  2216. except that all the named variables are left visible. These variables
  2217. will all remain when the RETURN statement deletes all the other variables
  2218. from the current function. If any of the named variables are not defined,
  2219. then they will remain undefined until they are assigned a value. This
  2220. value will then be carried back to the calling procedure.
  2221.  
  2222. It is not an error to specify a symbol more than once; this will have
  2223. the same effect as specifying it just once.
  2224.  
  2225. Simple symbols, stems or compound symbols may be exposed.  If a stem is
  2226. named, then all possible compound symbols starting with that stem will
  2227. be exposed.
  2228.  
  2229. BUG: It is not possible to expose a stem and one of its compound
  2230.      symbols at the same time.  If a stem is named and one of its
  2231.      compound symbols appears later, then the compound symbol has in
  2232.      effect already been exposed and so the expected results will
  2233.      occur.  However, if a stem appears after one of its compound
  2234.      variables, the stem will be ignored without a warning.
  2235.  
  2236. Any symbol(s) in the list following PROCEDURE EXPOSE may be enclosed in
  2237. parentheses.  In such cases the value of the symbol is used as a list
  2238. of extra symbols to expose.  For example, if the assignment:
  2239.      list = "var1 var2 stem. misc.3"
  2240. occurred in the calling program, then the instruction:
  2241.      procedure expose test1 (list) test2
  2242. will expose the following symbols (in this order):
  2243.      test1 list var1 var2 stem. misc.3 test2
  2244. Notice that the symbol inside the parentheses is itself exposed before
  2245. its value is obtained.
  2246.  
  2247. LOCAL: The PROCEDURE HIDE varlist command hides only the named variables,
  2248.       leaving the rest visible. On return the hidden variables are
  2249.       deleted, leaving all the others. The action of PROCEDURE HIDE list
  2250.       is identical to that of
  2251.       PROCEDURE EXPOSE <every existing variable except those named>.
  2252.       (in fact what happens is that all existing symbols are exposed and
  2253.       then the named symbols are deleted from the new variable table.
  2254.       This command is therefore quite inefficient and should be used
  2255.       sparingly).
  2256.       The PROCEDURE HIDE statement may not hide individual compound
  2257.       variables. Only stems and simple symbols should be specified,
  2258.       otherwise a syntax error will result.
  2259. NOTE: This means that variables which are undefined when the
  2260.       PROCEDURE HIDE statement is executed will be deleted on return from
  2261.       the current function. However, if new compound variables are 
  2262.       defined having a stem in common with some compound variables which
  2263.       already exist, then the new compound variables will not be deleted
  2264.       on return.
  2265.  
  2266. NOTE: As in standard REXX, the order in which the symbols are named can
  2267.       have an effect. For example, if i=5 then
  2268.          procedure expose i a.i
  2269.       will expose i and the compound symbol a.5, but
  2270.          procedure expose a.i i
  2271.       will expose the compound symbol a.I and i. This is because the
  2272.       names are processed from left to right, and in the latter case the
  2273.       symbol i is not visible when the name a.i is encountered.
  2274.  
  2275. The PROCEDURE command will almost invariably be at the beginning of a
  2276. function or procedure. It may be used in the middle rather than at the
  2277. beginning, but this is not recommended. In fact the ANSI standard
  2278. states that PROCEDURE must be the first instruction of a subroutine, if
  2279. it is present. In any case, an error will result if it is used within
  2280. an INTERPRET, or a DO, or some other control structure.
  2281.  
  2282. Example: an improved version of the above factorial program
  2283.         parse arg x
  2284.         say x"!="fact(x)
  2285.         exit
  2286.  fact:  procedure           /* now we get a different p each time */
  2287.         parse arg p
  2288.         if p<3 then return p
  2289.         return fact(p-1) * p
  2290.  
  2291. NOTE: The special variable SIGL must be explicitly exposed if its current
  2292.       value is needed within the procedure.  It is set by the CALL
  2293.       instruction or the function call before any PROCEDURE instruction
  2294.       is encountered.
  2295. _________________________________________________________________________
  2296.  
  2297. INTERPRET string
  2298.  
  2299. This command evaluates the given string and interprets it as if it were
  2300. part of a real rexx program. The string may contain any commands that
  2301. the program line containing the INTERPRET command might have executed
  2302. except that any DO or SELECT control blocks within the string must be
  2303. complete.  That is, the string may not start any new DO or SELECT
  2304. control blocks to be continued by the main program, and nor can it
  2305. contain an END, LEAVE, WHEN, etc. corresponding to a control block of
  2306. the main program.  An interpreted command can, however, cause a return
  2307. from a function.
  2308.  
  2309. NOTE: Interpreted strings should not contain labels. If they are present
  2310.       then they will be ignored.
  2311.  
  2312. Example: This program evaluates an expression given on the command line:
  2313.  
  2314. #!/mclab/imc/sun4/rexx -
  2315. parse arg x
  2316. interpret "y="||x
  2317. say x"="y
  2318. _________________________________________________________________________
  2319.  
  2320. SIGNAL [VALUE] name
  2321.  
  2322. In this form, the SIGNAL instruction is a primitive form of `goto'.
  2323. Using it to control program flow in this manner is strongly discouraged.
  2324.  
  2325. When this command is encountered interpretation jumps to the named label
  2326. (SIGNAL labels work just like procedure labels - but SIGNAL never invokes
  2327. another rexx program).
  2328.  
  2329. If the VALUE keyword is present, or if the name does not start with a
  2330. symbol or a string constant, then the name is treated as an expression
  2331. which must evaluate to the name of a label (irrespective of case).
  2332.  
  2333. All current DO and SELECT structures within the current procedure are
  2334. terminated by the SIGNAL instruction before the jump is taken.
  2335.  
  2336. When the SIGNAL instruction is executed, the variable SIGL is set to hold
  2337. the number of the line at the time of the jump. This can be used in
  2338. error analysis - as in:
  2339.  
  2340.   if something_is_wrong then signal error
  2341.   ...
  2342.   error: say "Something is wrong at line" sigl
  2343.  
  2344. or it can be used to type out long texts or help - as in:
  2345.  
  2346.    <lots of argument checking>
  2347.    if something_is_wrong then signal help /*
  2348.    This is a paragraph of help. It is enclosed in comments, so
  2349.    the interpreter ignores it. However the help routine will
  2350.    use the sourceline function to type it out on to the screen.
  2351.    */
  2352.    ...
  2353.    help: do i=sigl+1 while sourceline(i)~="*/"
  2354.    say sourceline(i)
  2355.    end
  2356.  
  2357. The SIGNAL VALUE construction is useful for calling procedures with
  2358. variable names. This can be done as follows:
  2359.  
  2360.    /* procname is set to the name of a procedure */
  2361.    call jumpto procname,arguments
  2362.    ...
  2363.    jumpto: parse arg jumpname
  2364.    signal value jumpname
  2365.    ...
  2366. When the named procedure is called, its first argument will be its name,
  2367. and the subsequent arguments will be those supplied by the caller.
  2368. The DO and SELECT structures in the calling program are protected from
  2369. the SIGNAL instruction, since the latter is encountered within procedure
  2370. `jumpto'.
  2371.  
  2372. SIGNAL ON  condition [NAME symbol]
  2373. SIGNAL OFF condition
  2374.  
  2375. These instructions maintain exception handlers for the following
  2376. contitions:
  2377.  
  2378.  SYNTAX:   Any syntax error (for example "Bad arithmetic conversion" or
  2379.            "Unexpected ',' or ')'") which occurs during interpretation.
  2380.  NOVALUE:  A variable name is used which has no value.
  2381.            NOTE: This condition is not raised during interpretation of
  2382.                  sub-names in compound variables. Hence, if `foo' has no
  2383.                  value, then "a=foo+1" will cause a novalue error but
  2384.                  "a=abc.foo" will not cause an error unless ABC.'FOO' has
  2385.                  no value.  Also, the builtin function VALUE() will never
  2386.           raise the NOVALUE condition.
  2387.  HALT:     The user has attempted to halt the program, for example by
  2388.            typing Control-C.  Signals SIGHUP and SIGTERM also raise the
  2389.        HALT condition.
  2390.  FAILURE:  A command to the environment returned a "failure" code.
  2391.            Usually this means a negative return code, but see the
  2392.        section on commands to the environment.
  2393.  ERROR:    A command to the environment returned an "error" code.
  2394.            This means a non-zero return code.  Note that if "failures"
  2395.            are not being trapped, then "error" will catch failures
  2396.            also.
  2397.  NOTREADY: A function from the REXX I/O model (see the separate section)
  2398.            was unsuccessful because, for example, an input function
  2399.            encountered an end-of-file condition.
  2400.        
  2401. (These are the same conditions as for CALL ON, with the two extra
  2402. conditions SYNTAX and NOVALUE).
  2403.  
  2404. The SIGNAL ON instruction turns on condition handling.  Whenever the
  2405. specified condition occurs, a SIGNAL is made to a handler.  If the NAME
  2406. keyword is specified, then the following symbol is taken as the name of
  2407. the handler.  Otherwise the handler has the same name as the condition.
  2408. At this point, RC holds the number of the error which caused the jump
  2409. (except in the case of NOTREADY) and SIGL holds the line number in
  2410. which the error occurred.  The routine in which the SIGNAL ON
  2411. instruction was encountered becomes the current routine; all internal
  2412. routines which became active since then are terminated.  All
  2413. DO/SELECT/IF control structures within the current routine are also
  2414. terminated.  The SIGNAL ON instruction is then cancelled, and another
  2415. SIGNAL ON instruction will be necessary to reinstate handling of this
  2416. particular condition.
  2417.  
  2418. At any time after control is passed to the handler, and before the
  2419. handler causes a return from the current subroutine, the CONDITION()
  2420. builtin function may be used to retrieve information about the
  2421. condition which was trapped.
  2422.  
  2423. A SIGNAL OFF instructions cancels condition handling for a particular
  2424. condition.  If handling is turned off for ERROR, FAILURE, NOTREADY or
  2425. NOVALUE, then the condition will be ignored whenever it occurs.  If
  2426. handling is turned off for HALT or SYNTAX, then the program will halt
  2427. when the condition occurs.
  2428.  
  2429. Condition handling persists from the point of the SIGNAL ON instruction
  2430. until the current function returns, or until a SIGNAL OFF instruction
  2431. is executed.  If an external routine is called, condition handling will
  2432. be turned off temporarily until the external routine finishes or turns
  2433. condition handling on.
  2434.  
  2435. The status of condition handling is saved across function calls.  If a
  2436. subroutine uses a "SIGNAL ON/OFF" or "CALL ON/OFF" instruction, the
  2437. condition handling within the current routine will be unaffected.
  2438.  
  2439. NOTE: The SIGNAL ON SYNTAX command does not trap fatal system errors or
  2440.       the error which is caused when EXIT or RETURN returns a non-integer
  2441.       to the UNIX environment (this is because the latter is, in effect,
  2442.       raised by the environment rather than by the interpreter itself).
  2443. _________________________________________________________________________
  2444.  
  2445. TRACE [symbol]
  2446. TRACE "string"
  2447. TRACE VALUE expression
  2448.  
  2449. The symbol, string constant or expression is evaluated (the VALUE keyword
  2450. may be omitted if the expression does not start with a symbol or a string
  2451. constant).  It must evaluate to a word consisting of zero or more
  2452. question marks, followed by an optional letter, followed by an optional
  2453. string of characters. Each question mark at the start of the string
  2454. toggles the `interactive tracing' mode (see below), and the following
  2455. letter, if any, is translated to upper case and must be one of the
  2456. following:
  2457.  
  2458.    A (All):      all clauses are traced before execution
  2459.    C (Commands): all commands to the environment are traced before
  2460.                  execution, together with the actual string passed to
  2461.                  the environment. If the command results in a non-zero
  2462.                  return code, then the return code is traced after
  2463.                  execution.
  2464.    E (Error):    Any command to the environment resulting in an error
  2465.                  (i.e. non-zero return code) is traced after execution,
  2466.                  together with the return code
  2467.    F (Failure):  Any command to the environment resulting in failure
  2468.                  (i.e. negative return code) is traced after execution,
  2469.                  together with the return code
  2470.    I (Intermediates): All clauses are traced before execution, and all
  2471.                  calculations are traced, including intermediate values
  2472.                  evaluated during the calculation. Assignments made by
  2473.                  PARSE instructions are also traced.
  2474.    L (Labels):   All labels passed during execution are traced
  2475.    N (Normal):   the default setting - same as F.
  2476.    O (Off):      Nothing is traced, and interactive tracing is also
  2477.                  switched off.
  2478.    R (Results):  All clauses are traced before execution, and the results
  2479.                  from all calculations are traced. Assignments made by
  2480.                  PARSE instructions are also traced.
  2481.  
  2482. If no setting is specified, then interactive tracing is turned off and
  2483. tracing is set to "N".
  2484.  
  2485. When clauses are being traced (i.e. A, R or I), when an INTERPRET command
  2486. is traced, the actual string being interpreted is also traced. When an
  2487. END command is traced, the source statement to which the END corresponds
  2488. is also traced.
  2489.  
  2490. A program may be made to trace itself during execution by signalling
  2491. it with SIGQUIT (on the Suns this can be done by pressing "control \").
  2492. When this signal is received, the tracing mode switches to "?i". If
  2493. a SIGQUIT is received whilst in interactive tracing mode and if an
  2494. interruption has already been received but not handled, the program
  2495. exits immediately (as is the case when SIGQUIT is not handled).  This
  2496. feature exists mainly to stop the interpreter in case of a bug.
  2497.  
  2498. A program may be made to trace itself when execution starts by using the
  2499. "-t" commandline flag (see the invocation section for details).
  2500.  
  2501. Interactive tracing
  2502.  
  2503. In interactive trace mode, all TRACE instructions passed in the program
  2504. are ignored and the interpreter will pause after tracing each clause,
  2505. label, command or return code (as appropriate for the trace setting).
  2506. The interpreter prompts for input with the string ">trace>".
  2507.    If an empty line is entered (without spaces), execution of the
  2508. program continues normally until the next event which is traced.
  2509.    If a line of REXX is entered, then that line is interpreted with
  2510. tracing set to "E".  If the line calls a program, then TRACE
  2511. instructions in that program are ignored. If the line itself uses the
  2512. TRACE instruction, then the trace setting is altered accordingly and
  2513. execution of the program will continue after the input line has been
  2514. interpreted.
  2515.    If the input line does not contain a TRACE instruction, then when it
  2516. has been interpreted the prompt will reappear for more input.
  2517.    If an error occurs during interpretation of the input line, a message
  2518. is displayed and the prompt reappears (unless the command executed a
  2519. TRACE instruction). The error does not cause the program to exit, and
  2520. no signalling takes place (unless the error occurred in a program which
  2521. was called by the input line and which contains its own SIGNAL ON xxx
  2522. command).
  2523.    Commands to the environment within the string will not set the
  2524. variable RC, but will have non-zero return codes traced.
  2525.    All condition traps are turned off during interpretation of the
  2526. string.
  2527.  
  2528. It is possible to make the interpreter change tracing and also prompt
  2529. for more input by using the built-in TRACE function rather than the
  2530. TRACE instruction, for example:
  2531.    call trace r
  2532. sets the `results' tracing mode (whilst keeping interactive mode) without
  2533. continuing execution of the program.
  2534.  
  2535. The interactive tracing mode is useful for the following purposes (and
  2536. others):
  2537.    - single-stepping through a program (use trace ?a)
  2538.    - setting breakpoints (use trace ?l and put a label at the breakpoint)
  2539.    - examining or changing variables during execution.
  2540.  
  2541. The input line is interpreted in exactly the same way as with the
  2542. INTERPRET command, and so the same restrictions apply (e.g. DO and END
  2543. instructions etc must be matched properly).
  2544.  
  2545. BUG:The following also applies, however:
  2546.   - some of the source information is lost, so any PARSE SOURCE
  2547.     instruction in the line will have the calling method and the calling
  2548.     name replaced by "TRACE" (this does not apply to PARSE SOURCE
  2549.     instructions within programs that may be called by the input line).
  2550.  
  2551. If the input line transfers control by a SIGNAL instruction, then control
  2552. is immediately transferred to the target instruction and it is executed
  2553. before tracing resumes. If the input line contains a RETURN or EXIT
  2554. instruction, then execution returns to the caller and continues to the
  2555. end of the current statement. The return may cause a change in the
  2556. tracing mode, since this is saved across function calls. However, if
  2557. interactive tracing is still in effect, then tracing will resume at the
  2558. next instruction.
  2559.  
  2560. NOTE:If the interpreter has a controlling terminal (that is, "/dev/tty"
  2561.      can be opened when the interpreter initialises), then the trace
  2562.      prompt will be written to the terminal, and input will be read from
  2563.      the terminal. Otherwise, stderr and stdin are used respectively.
  2564.      If an error occurs during a command which was typed in interactive
  2565.      trace mode, then the error message will be written to the terminal.
  2566.      However, all normal input and output use stdin and stdout, while
  2567.      trace output is written to the requested file (see OPTIONS).  In
  2568.      particular, if tracing has been redirected, then no trace output
  2569.      will appear on the terminal. Therefore it is not a good idea to
  2570.      redirect tracing when interactive tracing will be used.
  2571.  
  2572. BUG: Interactive tracing is not recursive, i.e. if, during interactive
  2573.      tracing, a line is entered such as:
  2574.         trace i;say a+b
  2575.      then the tracing of "say a+b" (and other statements following the
  2576.      TRACE instruction) will not be interactive, even though the
  2577.      interactive tracing mode is (in theory) still in operation.
  2578.  
  2579. TRACE output
  2580.  
  2581. Each line of trace output is preceded by three characters which identify
  2582. the type of trace output. Any clause or command traced will be indented
  2583. according to its logical depth of nesting. Results (or intermediate
  2584. values) will be indented a further two spaces, and have leading and
  2585. trailing quotes added. The line numbers of source statements and labels
  2586. are displayed before the three-character prefix.  An interpreted
  2587. instruction or a command about to be executed will be displayed without
  2588. a line number.
  2589.  
  2590. The three-character prefixes are:
  2591.  
  2592. +++ A trace message (an error message, or the return code from a command)
  2593.  
  2594. *-* A source statement. This is either the actual text of a statement
  2595.     within a program, or a representation of a statement generated by
  2596.     an INTERPRET statement.
  2597. *~* The result of evaluating an expression which is either a command to
  2598.     be passed to the environment or the parameter of an INTERPRET
  2599.     instruction.
  2600. *=* A label.
  2601.  
  2602. >>> The result of an expression displayed in "trace r", or the value
  2603.     assigned to a variable during parsing or during update of the
  2604.     control variable of a repetitive DO loop.
  2605. >.> The value `assigned' to a placeholder (dot) during parsing.
  2606.  
  2607. The following prefixes are used during TRACE I:
  2608.  
  2609. >V> The contents of a variable
  2610. >L> a literal (that is, a constant symbol or number, an uninitialised
  2611.     variable, or a string/hex/binary constant)
  2612. >F> The result of applying a function
  2613. >P> The result of applying a prefix operator
  2614. >O> The result of applying a (binary) operator
  2615. >C> The name of a compound variable (after substitution and before use).
  2616.  
  2617. The trace setting is saved across function calls, so that if tracing is
  2618. switched on or off during a function, the previous setting is restored
  2619. when the function returns. This means that:
  2620.   - if a function is known to work, then "trace off" may be placed at
  2621.     the start. When a program is being traced, tracing is switched off
  2622.     when the function is entered, and back on when the function returns.
  2623.   - if a function is known not to work, then a trace instruction placed
  2624.     at the start of the function will switch tracing on only for the
  2625.     duration of the function call.
  2626. _________________________________________________________________________
  2627.  
  2628. OPTIONS expression
  2629.  
  2630. The expression is evaluated and broken into blank-delimited words.
  2631. Each word is examined to see if it is recognised as a valid interpreter
  2632. option for this implementation.  Any word which is not recognised is
  2633. skipped over, since it probably applies to some other implementation.
  2634.  
  2635. In REXX/imc, the case of the options is not significant, and options
  2636. may be abbreviated.  The minimum abbreviation for each option is shown
  2637. in uppercase.  Options which require an '=' are only recognised if the
  2638. '=' sign is present and followed by a valid string. 
  2639.  
  2640. REXX/imc currently recognises the following option:
  2641.  
  2642.  TRACEfile=filespec  If "filespec" represents a filename which can be
  2643.                      opened for writing, then an information message is
  2644.              written to the standard output and all trace output
  2645.              is redirected to the named file.  Otherwise an
  2646.              error message is written to the standard error and
  2647.              tracing remains unchanged.
  2648. _________________________________________________________________________
  2649.  
  2650. ADDRESS [VALUE] [environment]
  2651. ADDRESS environment command
  2652.  
  2653. When  the REXX interpreter finds a program statement which is not an
  2654. instruction (as listed above), then it evaluates the whole statement as
  2655. an expression (if it can), and issues the resulting string to the
  2656. current environment as a command.
  2657.  
  2658. The first form of the ADDRESS instruction stated above changes the
  2659. environment (until the next ADDRESS instruction).  If the environment
  2660. name is given, it may be a symbol (which is translated to upper case,
  2661. but not substituted by its value) or a string constant, or a string
  2662. expression preceded by the keyword VALUE.  The VALUE may be omitted if
  2663. the expression does not start with a symbol or a string constant.  The
  2664. current environment is changed to the given string.
  2665.  
  2666. If no environment name follows the ADDRESS instruction, then the previous
  2667. environment is made current.  For example:
  2668.  
  2669.    address unix       /* "UNIX" is current   */
  2670.    address "MY_ENV"   /* "MY_ENV" is current */
  2671.    address            /* "UNIX" is current   */
  2672.    address            /* "MY_ENV" is current */
  2673.  
  2674. The second form of the ADDRESS instruction given above executes a command
  2675. in a given environment without changing the current environment.  The
  2676. environment name must be a symbol or string constant, and the command may
  2677. be any string expression.  So, if the following line is appended to the
  2678. previous example:
  2679.  
  2680.    address command "ls -al"
  2681.  
  2682. the command "ls -al" is executed in environment "COMMAND", while the
  2683. current environment is still "MY_ENV".
  2684.  
  2685. Whenever a command is executed, the special variable RC is set to the
  2686. return code given by the command.  If this return code is non-zero,
  2687. then the command will also cause a FAILURE or ERROR condition to be
  2688. raised.  These conditions are ignored unless trapped by CALL ON or
  2689. SIGNAL ON.
  2690.  
  2691. Currently, only two environments are supported:
  2692.  
  2693. ADDRESS UNIX
  2694.  
  2695. Each command sent to the "UNIX" environment is executed in a separate
  2696. Bourne shell.  Note that this involves considerable overhead, and
  2697. moreover no command can make a permanent change to the environment (e.g.
  2698. "set" and "export" will have no effect).  However, it does allow the
  2699. flexible syntax of the Bourne shell to be used, including piping, I/O
  2700. redirection, and filename expansion.
  2701.  
  2702. In this environment, any command which returns a code of 1 will raise
  2703. the FAILURE condition, as well as any command which returns a negative
  2704. return code.  This is because the Bourne shell always returns 1 when
  2705. it fails to find the requested command.
  2706.  
  2707. ADDRESS COMMAND
  2708.  
  2709. Each command sent to the "COMMAND" environment is tokenised and executed
  2710. by a primitive shell which is built into the interpreter (in shell.c).
  2711. This makes for quicker execution of each command, but note that at
  2712. present the only "meta-characters" which are supported are quotes.  That
  2713. is, enclosing a string in quotes passes it verbatim (i.e. untokenised)
  2714. as a parameter to a command.  In particular, piping, file redirection
  2715. and filename expansion are not supported.  Nor does this shell have any
  2716. builtin commands (such as cd, set), with the exception of "hash" (see
  2717. later).  For speed of execution, each time a command is executed its
  2718. path is remembered in a hash table.  The hash table statistics may be
  2719. obtained with the "hash" builtin command, which is similar to that of
  2720. the Bourne shell (and bash).  The command "hash name1 [name2 ...]" will
  2721. search for each of the given names and add the results to the hash
  2722. table, but if any of the names is "-r" then the hash table will be
  2723. cleared.  The names are examined from left to right, so "hash cat -r
  2724. ls" will result in just "/bin/ls" in the hash table.  The hash table is
  2725. also cleared whenever putenv() or value(,,"ENVIRONMENT") is used to
  2726. change PATH.  The command "hash" will print out the list of hash table
  2727. entries.  "hits" represents the number of times a command has been
  2728. looked up in the table, and "cost" represents the amount of work which
  2729. was initially carried out in searching along the path for the command.
  2730. A plus-sign in column 1 indicates that the entry was placed in the same
  2731. hash bucket as the previous entry; the commands within hash buckets are
  2732. arranged in alphabetical order.  The hash buckets are listed in no
  2733. particular order.
  2734.  
  2735. In this environment, an unrecognised command produces return code -3.
  2736. Any command which produces a negative return code will raise the
  2737. FAILURE condition.
  2738.  
  2739. If a command is sent to an unrecognised environment, then return code
  2740. -3 and a FAILURE condition results.
  2741.  
  2742. The environment when a program starts up is usually UNIX.  The current
  2743. environment may be found by calling address(), and the environment at
  2744. startup may be found using "parse source".
  2745.  
  2746. Here is a simple shell program to demonstrate the use of commands:
  2747.  
  2748. do i
  2749.    sayn i'>'
  2750.    parse pull command
  2751.    parse upper var command word .
  2752.    if word='EXIT' then exit
  2753.    command
  2754.    if rc!=0 then say "The return code was" rc
  2755. end i
  2756.  
  2757. Each command is read from standard input. If the command 'Exit' is
  2758. received, the shell quits. Otherwise, the command is issued to a Bourne
  2759. Shell and the return code is checked.
  2760.  
  2761. NOTE: The program rxstack (in Oxford /mclab/imc/{misc,sun3,sun4}/rxstack)
  2762.       may be used to access the stack while executing a shell command.
  2763.       See the stack section below for details.
  2764. _________________________________________________________________________
  2765.  
  2766. The REXX I/O Model
  2767.  
  2768. Standard REXX allows files to be accessed using seven the functions
  2769. charin, charout, chars, linein, lineout, lines, stream.  This REXX
  2770. version has fourteen I/O functions in total; the others remain for
  2771. backward compatibility but may be removed in future because their
  2772. functionality is covered by the stream() function.
  2773.  
  2774. Each I/O function may accept a stream name as a parameter.  Usually,
  2775. the stream name is the path name of a file which will be accessed -
  2776. though other meanings may be given to streams by the "open", "popen"
  2777. and "stream" functions.
  2778.  
  2779. Associated with each currently accessed stream is a read pointer and a
  2780. write pointer.  Characters or lines can be read from the file at the
  2781. position indicated by the read pointer, or they may be written to the
  2782. file at the position indicated by the write pointer.  In each case the
  2783. pointer is updated to indicate the new file position after the read or
  2784. write.  The file pointers may be also moved explicitly by various
  2785. functions.  Note that the read and write pointers will in general be
  2786. different, in contrast to the usual Unix file pointer.
  2787.  
  2788. Each file is opened by REXX when it is first accessed, and closed when
  2789. REXX exits.  Therefore files need not be opened and closed explicitly,
  2790. though in this version functions are provided for that purpose.  If
  2791. many files are to be accessed, it is advisable to close files which are
  2792. no longer needed because otherwise the Unix error "Too many open files"
  2793. may result.
  2794.  
  2795. Two kinds of stream exist: persistent and transient.  A persistent
  2796. stream is one which refers to a regular file, whereas a transient
  2797. stream is any other kind.  In particular, ttys and pipes are transient
  2798. streams.  The main difference between the two is that the read and write
  2799. pointers of a permanent stream may be repositioned, whereas those of a
  2800. transient stream may not.
  2801.  
  2802. If a function encounters an I/O error and is unable to perform its
  2803. function, then it will raise the NOTREADY condition.  This condition
  2804. will be ignored unless it is trapped by SIGNAL ON or CALL ON.  However,
  2805. in all cases it is possible to examine the most recent I/O error using
  2806. the STREAM() function.
  2807.  
  2808. The three streams "stdin", "stdout" and "stderr" are already open when
  2809. REXX starts up.  They may be used just as any other files, but they are
  2810. also accessed by instructions such as "say" and "pull", and by Unix
  2811. commands.  Because of this, REXX/imc only guarantees to be well-behaved
  2812. if stdin is never written to, and stdout and stderr are never read from.
  2813.  
  2814. The I/O functions, and their descriptions, follow.  Note that no
  2815. "stream" or "file" name may contain a NUL character (i.e. "00"x).
  2816.  
  2817. CHARIN([stream] [,[position] [,count]])
  2818.  
  2819. If stream is supplied, it is read from, otherwise "stdin" is read.  The
  2820. charin function attempts to read a character from the stream, and
  2821. returns the result.  If count is supplied, then that many characters
  2822. are read and returned.  The length of the result may be less than the
  2823. number of characters requested if an error occurs.  If position is
  2824. supplied, then the read pointer is seeked to that position (with 1
  2825. being the first character of the stream) before reading.  If count is
  2826. zero, then the seek is performed without reading any characters.
  2827.  
  2828. If count>0 and no characters are read then the NOTREADY condition will
  2829. be raised.
  2830.  
  2831. If an interruption (^C) occurs during the read, then characters already
  2832. read may be lost.
  2833.  
  2834. NOTE: In order to read single characters from the keyboard, it is
  2835.       necessary to set the terminal into a suitable mode.  For example
  2836.       the Unix command "stty cbreak -echo" allows single characters
  2837.       to be read without echoing.  This should be reset with
  2838.       "stty -cbreak echo" before the program exits.
  2839.  
  2840. CHAROUT([stream] [,[string] [,position] ]
  2841.  
  2842. If stream is supplied, it is written to, otherwise stdout is written to.
  2843. If the string is supplied, it is written to the stream, otherwise no
  2844. write is performed.  If the position is supplied, the write pointer is
  2845. set to that position (with 1 being the first character) before the
  2846. write (if any).
  2847.  
  2848. If no string and no position are supplied, then all pending output to
  2849. the stream is flushed, and the write pointer is set to the end of the
  2850. stream.
  2851.  
  2852. The result will be the number of characters left unwritten, and if that
  2853. is non-zero then the NOTREADY condition will be raised.
  2854.  
  2855. CHARS([stream])
  2856.  
  2857. The result will be the number of characters which are immediately
  2858. available for reading from stream or, if it is omitted, from "stdin".
  2859. If the stream is not open and does not name a file which can be read,
  2860. zero will be returned and the NOTREADY condition raised.
  2861.  
  2862. CLOSE(stream)
  2863.  
  2864. The named stream is closed and REXX's table of information for that
  2865. stream is deleted.  The result will be the return code from the close
  2866. system call.
  2867.  
  2868. NOTE: if stream is one of "stdin" or "stdout" then future input or output
  2869.       operations with "say" and "pull" will fail to work properly.
  2870.  
  2871. This call is equivalent to STREAM(stream,'c','close) and may be deleted
  2872. in future releases.
  2873.  
  2874. FDOPEN(fd [,[mode] [,stream]])
  2875.  
  2876. This function is for accessing files which have already been opened by
  2877. another program and whose file descriptor numbers are known.  It should
  2878. not be used for opening files to which REXX already has access.
  2879.  
  2880. If mode is supplied, its first character must be one of "r" or "w",
  2881. meaning that the descriptor is to be opened for reading or read-write
  2882. respectively. The default is "r".  This mode should match the mode of
  2883. the already-open file descriptor.
  2884.  
  2885. If the stream argument is supplied, then the given fd will be opened and
  2886. given that name so that all future references to the fd will call it by
  2887. the given name.  Otherwise, future references to the fd will be by its
  2888. number.
  2889.  
  2890. If a stream argument is supplied which names an open stream, that
  2891. will be closed first.  Note that the new stream will be opened on a
  2892. different descriptor, so in particular this function should not be used
  2893. to redirect the standard input, output or error.
  2894.  
  2895. The result from fdopen will be the return code given by the fdopen
  2896. system call.
  2897.  
  2898. Example. If this program is called "foo.exec":
  2899.  
  2900.     /* write to file descriptor 3 */
  2901.     call fdopen 3,"w"
  2902.     call lineout 3,"This is a line of text"
  2903.  
  2904. then the Bourne Shell command "rexx foo 3>foobar" will write a line of
  2905. text to the file foobar.
  2906.  
  2907. This call is equivalent to STREAM(stream,'c','fdopen' [mode] [,fd]) and
  2908. may be deleted in future releases.
  2909.  
  2910. FILENO(stream)
  2911.  
  2912. The result of this function is the file desriptor number associated with
  2913. the named stream, or -1 if that could not be determined (for example, the
  2914. stream is not open).  This function may be used to pass file descriptors
  2915. on to shell commands, for instance as in "cat <&7".
  2916.  
  2917. This call is equivalent to STREAM(stream,'c','fileno') and may be
  2918. deleted in future releases.
  2919.  
  2920. FTELL(stream)
  2921.  
  2922. The result of this function is the current file pointer associated with
  2923. the given stream (with 1 meaning the beginning), that can be used as a
  2924. position parameter to the charin or charout calls.  If that could not
  2925. be determined (for example, the stream is a pipe or is not open) then -1
  2926. will be returned.
  2927.  
  2928. NOTE: This is the actual file pointer, not the read or write pointer as
  2929.       stored by REXX (though the answer will probably equal one of those,
  2930.       according as to whether the last operation on the stream was a read
  2931.       or a write).
  2932.  
  2933. This call is equivalent to STREAM(stream,'c','ftell') and may be
  2934. deleted in future releases.
  2935.  
  2936. LINEIN([stream] [,[line] [,count]])
  2937.  
  2938. If stream is supplied, it is read from, otherwise "stdin" is read.  The
  2939. linein function attempts to read a line from the stream, and returns the
  2940. result (with the terminating newline character removed).  If count is
  2941. supplied, it must be zero or one.  If zero, then no read is performed,
  2942. and if one, one line is read.  If an error occurs and no characters have
  2943. been read, then an empty string is returned and the NOTREADY condition
  2944. is raised.  If line is supplied, then the read pointer is seeked to
  2945. that line number (with 1 being the first line of the stream) before
  2946. reading.  If count is zero, then the seek is performed without reading
  2947. any characters.
  2948.  
  2949. If an interruption (^C) occurs during the read, then characters already
  2950. read may be lost.
  2951.  
  2952. NOTE: Seeking by line number is very inefficient, because every
  2953.       character of the stream before that line has to be read (unless the
  2954.       current read pointer is at a known line number less than that
  2955.       requested, in which case only every character between the current
  2956.       read position and the required position need be read).
  2957.  
  2958. LINEOUT([stream] [,[string] [,line]])
  2959.  
  2960. If stream is supplied, it is written to, otherwise stdout is written to.
  2961. If the string is supplied, it is written to the stream and terminated
  2962. with a newline character, otherwise no write is performed.  If line is
  2963. supplied, the write pointer is set to that line number (with 1 being the
  2964. first line) before the write (if any).  The line must not contain any
  2965. newline characters, because these will act as line separators in the
  2966. stream.  To write text containing newline characters, please use charout
  2967. instead.
  2968.  
  2969. If no string and no line number are supplied, then all pending output to
  2970. the stream is flushed, and the write pointer is set to the end of the
  2971. stream.
  2972.  
  2973. The result will be 1 if the line was not successfully written, in which
  2974. case the NOTREADY condition will be raised.  Otherwise the result will
  2975. be zero.
  2976.  
  2977. NOTE: seeking by line number is very inefficient.
  2978.  
  2979. LINES([stream])
  2980.  
  2981. If the named stream, or "stdin" if no stream is named, is a persistent
  2982. stream (or the name of a regular file), then the number of lines
  2983. available for reading will be counted and returned.  Note that this
  2984. implies reading every character remaining in the file, and this should
  2985. be avoided if possible.
  2986.  
  2987. If the stream is a transient stream, then the result will be "1" if
  2988. characters may be read immediately from the stream, and "0" otherwise.
  2989. It is impossible to calculate the exact number of lines in this case.
  2990.  
  2991. If the stream is not already open and does not name a file which can be
  2992. read, then zero will be returned and the NOTREADY condition raised.
  2993.  
  2994. OPEN(file [,[mode] [,stream]])
  2995.  
  2996. The file specified is opened, if possible, and the error code from the
  2997. system call is returned.  If mode is omitted, then the file is opened
  2998. for reading only, otherwise the first character of the mode must be
  2999. "r" (to open for reading), "w" (to open for read/write, with the file
  3000. being created or truncated initially), or "a" (to append, i.e. open for
  3001. read/write with the write pointer at the end of any existing data in the
  3002. file initially).
  3003.  
  3004. This function will not raise the NOTREADY condition, nor will it record
  3005. any error for STREAM() - the stream will remain unopened (or "UNKNOWN")
  3006. if the open fails.  The return code from the call should be checked to
  3007. see whether an error occurred.
  3008.  
  3009. If the stream argument is supplied, then any future reference to the
  3010. open file will use this as the stream name - otherwise the filename
  3011. (exactly as specified in the open function call) will be used.
  3012.  
  3013. If a stream argument is supplied which already refers to an open file,
  3014. then that will be closed and the new file will be opened on the same
  3015. descriptor.  The standard input, output or error may be redirected by
  3016. calling open with 'stdin', 'stdout' or 'stderr' as the stream argument.
  3017.  
  3018. This call is equivalent to STREAM(stream,'c','open' [mode][,file]) and
  3019. may be deleted in future releases.
  3020.  
  3021. PCLOSE(stream)
  3022.  
  3023. This function must be used to close any stream which was opened by the
  3024. popen function.  The result will be the error code from the pclose system
  3025. call, which will in turn be the exit code of the command being run at the
  3026. other end of the pipe if the pipe was closed successfully or -1 if not.
  3027. A result of -1 may mean that the given stream was not opened with popen.
  3028.  
  3029. This function will not raise the NOTREADY condition, nor will it record
  3030. any error for STREAM().
  3031.  
  3032. This call is equivalent to STREAM(stream,'c','pclose') and may be
  3033. deleted in future releases.
  3034.  
  3035. POPEN(command [,[mode] [,stream]])
  3036.  
  3037. A Bourne Shell is started off in the background to run the given command
  3038. with a one-way pipe leading from or to it.  If the mode is omitted, or
  3039. starts with the letter R, then the output of the command may be read
  3040. from the pipe.  If a mode starting with the letter W is given, then the
  3041. input of the command may be written down the pipe.
  3042.  
  3043. The return value from popen will be zero if the pipe was opened
  3044. successfully, or an error number if not.  Note that the pipe may still
  3045. be opened successfully even if the command can not be executed: it
  3046. is the Bourne Shell's job to report that the command can not be executed.
  3047. The return code from the shell can be obtained with the pclose function.
  3048.  
  3049. This function will not raise the NOTREADY condition, nor will it record
  3050. any error for STREAM().
  3051.  
  3052. If the stream argument is supplied, then any future reference to the pipe
  3053. will use this as the stream name - otherwise the command in full will be
  3054. used.
  3055.  
  3056. If a stream argument is supplied which already refers to an open
  3057. stream, then that will be closed after the pipe has been successfully
  3058. opened.  This means that the pipe will be opened on a different
  3059. descriptor, and the popen function should not be used to redirect the
  3060. standard input, output or error.
  3061.  
  3062. The pipe should be closed with the pclose function so that the shell
  3063. process may be removed from the process table.  If that is not done,
  3064. then defunct processes will remain until REXX exits.  This may be
  3065. acceptable for a small number of popen calls, but not if the REXX
  3066. program calls popen many times or is long-lived.
  3067.  
  3068. Example: the following program outputs in hex, using an "od" process:
  3069.  
  3070.     output= "/bin/od -x"
  3071.     call popen output,"w"
  3072.     call lineout output,"This is some sample output"
  3073.     call pclose output
  3074.  
  3075. This call is equivalent to STREAM(stream,'c','popen' [mode][,command])
  3076. and may be deleted in future releases.
  3077.  
  3078. STREAM(stream[,[option][,command]])
  3079.  
  3080. This function provides miscellaneous operations on the named stream.
  3081. The first character of the option must be "C", "D" or "S" (in upper or
  3082. lower case), if the option is given.  If the option is omitted, then
  3083. "S" is assumed.  The command parameter must be given if and only if the
  3084. option is "C".
  3085.  
  3086. Option "S"
  3087.  
  3088. The function returns the status of the stream as one of the following
  3089. strings:
  3090.  "READY"     - the stream is ready for input or output.
  3091.  "NOTREADY"  - the stream is not ready; usually this indicates that the
  3092.                end of the file was reached.
  3093.  "ERROR"     - an I/O error has occurred.
  3094.  "UNKNOWN"   - the stream has not been accessed.
  3095.  
  3096. Option "D"
  3097.  
  3098. The function returns a description of the stream's status.  This will
  3099. be "Ready", "Unknown", or the text of an error which has occurred.
  3100. This option may be used after a NOTREADY condition is trapped, to find
  3101. out what happened to the stream.
  3102.  
  3103. Option "C"
  3104.  
  3105. The function executes the given command on the stream and returns a
  3106. result depending on the command.
  3107.  
  3108. Valid commands in REXX/imc follow.  All command names and mode
  3109. parameters may be given in mixed case, and wherever a comma appears in
  3110. the command, a space is acceptable as long as the parameter before it
  3111. is not omitted.  For example, stream('file','c','Open R /tmp/testfile')
  3112. is a valid call to this function.
  3113.  
  3114.  close      - the named stream is closed and the return value from the
  3115.               system call is returned.  See CLOSE() for details.
  3116.  
  3117.  fdopen [mode][,number] - if the number is given, it is used as a
  3118.               numeric file descriptor and opened on the given stream.
  3119.           Otherwise, the given stream is taken to be a numeric file
  3120.           descriptor and opened.  If the mode is omitted, "r" is
  3121.           assumed.  The return value from the system call is
  3122.           returned.  See FDOPEN() for details.
  3123.  
  3124.  fileno     - the file descriptor corresponding to the given stream is
  3125.               returned.  See FILENO() for details.
  3126.  
  3127.  flush      - the named stream is flushed.  This is similar to calling
  3128.               charout(stream).
  3129.  
  3130.  ftell      - the file pointer of the given stream is returned.  See
  3131.               FTELL() for details.
  3132.  
  3133.  open [mode][,file] - if the file name is supplied, it is opened on the
  3134.           given stream.  Otherwise, the given stream is taken to be
  3135.           a file name and opened.  If the mode is omitted, "r" is
  3136.           assumed.  The return value from the system call is
  3137.           returned.  See OPEN() for details.
  3138.  
  3139.  pclose     - the stream, which must have been opened by "popen", is
  3140.               closed.  The return value from the system call is
  3141.           returned.  See PCLOSE() for details.
  3142.  
  3143.  popen [mode][,command] - if the command is supplied, a Bourne shell is
  3144.               started up to execute it.  Otherwise, the given stream
  3145.           name is assumed to be a command and the shell is started
  3146.           up to execute that.  A pipe is opened from the shell to
  3147.           the given stream.  If the mode is omitted, "r" is
  3148.           assumed.  The return value from the system call is
  3149.           returned.  See POPEN() for details.
  3150. _________________________________________________________________________
  3151.  
  3152. The REXX Stack
  3153.  
  3154. The REXX stack is implemented by a stack process, with which the
  3155. interpreter communicates by means of a socket. The PUSH, QUEUE, and PULL
  3156. instructions and the QUEUED() function all communicate with the stack
  3157. process.
  3158.  
  3159. If a stack exists, then the standalone program rxstack may be used to
  3160. stack or retrieve data. This can be used to communicate to rexx the
  3161. output of a command (for instance "ls -al | rxstack") or to input data
  3162. from rexx (for instance "rxstack -print > /tmp/file"). The invocation
  3163. syntax of this program is:
  3164.  
  3165. rxstack [-fifo|-lifo] [-print|-pop|-peek|-drop|-num|-string "data"]
  3166.  
  3167. The meaning of these flags is as follows:
  3168.    -fifo   stack in FIFO order (the default)
  3169.    -lifo   stack in LIFO order
  3170.    -print  empty the stack, outputting each item on standard output
  3171.    -pop    pop one item and output on standard output
  3172.    -peek   output the first item on standard output without deleting it
  3173.    -drop   discard one item
  3174.    -num    output the number of items currently stacked on standard
  3175.            output in decimal, followed by newline character
  3176.    -string interpret the next argument as a literal string to be stacked
  3177. If none of the above flags (except -fifo or -lifo) is specified, then
  3178. each line of standard input is stacked until an EOF is received.
  3179.  
  3180. Each stack item may comtain arbitrary characters, including newline
  3181. characters, but when rxstack takes input from standard input, all
  3182. newline characters are taken to be item separators and are deleted
  3183. before each item is stacked. Similarly, when rxstack outputs stack items
  3184. each item is followed by a newline character.
  3185.  
  3186. The name of the socket used for communication is stored in the
  3187. environment variable RXSTACK. It is assumed that a stack exists if and
  3188. only if this variable exists. Multiple processes may share the same stack
  3189. but multiple users may not usually share one stack because the sockets
  3190. for each user are kept in a separate protected directory belonging to
  3191. that user.
  3192.  
  3193. When REXX is invoked, if no stack exists then one is created, and is
  3194. destroyed when REXX exits. If a stack exists then REXX uses that stack.
  3195.  
  3196. The program rxque may be used to create a stack process independently of
  3197. REXX (for instance, so that REXX need not create one on startup, or so
  3198. that stack data may persist across invocations of REXX). This is done
  3199. by the program rxque. It may be invoked in three different ways:
  3200.  
  3201. rxque
  3202.    starts a stack process in the background and outputs two environment
  3203.    variables to stdout in the format
  3204.    RXSTACK=<name> RXSTACKPROC=<number>
  3205.    where RXSTACKPROC is the process number of the stack, which must be
  3206.    killed when the stack is no longer needed. To avoid unwanted processes
  3207.    being left around when errors occur, rxque will terminate itself if it
  3208.    finds that its parent process no longer exists when it has been
  3209.    sleeping for five minutes without communication.
  3210.    
  3211.    This output can either be parsed by a controlling program or used
  3212.    directly by a shell, for instance by:
  3213.    eval `rxque`;export RXSTACK RXSTACKPROC
  3214.  
  3215. rxque -csh
  3216.    is similar to the above but outputs two setenv commands in a format
  3217.    acceptable for the c-shell, so that
  3218.    eval `rxque -csh`
  3219.    will set the environment variables correctly in the c-shell.
  3220.  
  3221. rxque <filename>
  3222.    starts a stack process in the background which uses <filename> as the
  3223.    communication socket. This file will be deleted if it exists, before
  3224.    the socket with that name is opened. The process number of the stack
  3225.    process will be output to stdout, followed by a newline.
  3226.  
  3227. For instance:
  3228. % eval `rxque -csh`
  3229. % ls -al | rxstack -lifo
  3230. % rxstack -num
  3231. 45
  3232. % rxstack -print
  3233. [many lines deleted]
  3234. drwxr-xr-x 13 imc          1536 Oct 28 16:56 ..
  3235. drwx------  5 imc          1024 Oct 28 13:12 .
  3236. total 194
  3237. % kill $RXSTACKPROC
  3238. % unsetenv RXSTACK
  3239. % rxstack
  3240. RX Stack not found
  3241. _________________________________________________________________________
  3242.  
  3243. Error Messages
  3244.  
  3245. As far as is possible, this interpreter conforms to the standard
  3246. numbering system for error messages. Messages which may be produced by
  3247. this interpreter are as follows (explanations are omitted when the
  3248. meaning is obvious):
  3249.  
  3250. Failure returns (negative)
  3251.  
  3252. -3 Error loading program
  3253.    A message indicating the reason will usually be displayed
  3254.    immediately before this message.
  3255.    
  3256. -1 Initialisation error
  3257.    A failure in some essential service, such as not being able to start
  3258.    up the stack process.  Alternatively, some error occurred while
  3259.    processing the commandline arguments (in which case an explanation
  3260.    follows the message text).
  3261.  
  3262. Standard REXX errors (1-50)
  3263.  
  3264.  4 Program interrupted
  3265.    Control-C has been typed, or a SIGHUP or SIGTERM signal has been
  3266.    received.
  3267.  
  3268.  5 Machine storage exhausted
  3269.  
  3270.  6 Unmatched '/*' or quote
  3271.    (this is reported as the program is loaded, before execution. The line
  3272.    number given corresponds to the start of the string or comment which
  3273.    is unterminated. Alternatively, the error may occur during an
  3274.    INTERPRET instruction, in which case the INTERPRET instruction itself
  3275.    is named. This also applies to errors 13 and 37).
  3276.    
  3277.  7 Expected WHEN/OTHERWISE
  3278.    Either a SELECT is not followed immediately by a WHEN, or the end of
  3279.    the SELECT structure has been reached, no condition was true, and no
  3280.    OTHERWISE clause is present.
  3281.    
  3282.  8 Unexpected THEN/ELSE
  3283.  
  3284.  9 Unexpected WHEN/OTHERWISE
  3285.  
  3286. 10 Unexpected or unmatched END
  3287.  
  3288. 13 Invalid character in program: [char]
  3289.    The only characters which are allowed in program text (excluding
  3290.    comments and string constants) are spaces, tabs, newlines, the
  3291.    alphanumerics (A-Z, a-z, 0-9) and the symbols:
  3292.             @#.?!_$|&*()-+=^\'";:<,>%/
  3293.    (see also error 6)
  3294.  
  3295. 14 Incomplete DO/SELECT/IF
  3296.    An END is probably missing.
  3297.  
  3298. 15 Invalid binary or hexadecimal string
  3299.  
  3300. 16 Label not found: [label]
  3301.    The target of a SIGNAL (whether explicit or caused by a trap) is
  3302.    missing.
  3303.  
  3304. 17 Unexpected PROCEDURE
  3305.    The PROCEDURE instruction should only be placed directly after the
  3306.    entry point of a function.
  3307.    
  3308. 18 Expected THEN
  3309.  
  3310. 19 String or symbol expected
  3311.    A string or symbol was expected (e.g. after SIGNAL or NUMERIC FORM)
  3312.    but was missing or invalid.
  3313.    
  3314. 20 Symbol expected
  3315.    A symbol was expected (e.g. after PARSE VAR or, optionally, after
  3316.    LEAVE or ITERATE) but was missing or invalid.
  3317.  
  3318. 21 Invalid data on end of clause
  3319.    Extra characters were found when the interpreter expected a line end
  3320.    or a semicolon. In the special case of the END instruction, the symbol
  3321.    (or SELECT) appearing after the END did not match up with the
  3322.    beginning of the structure being ended.
  3323.    
  3324. 24 Invalid TRACE request
  3325.  
  3326. 25 Invalid subkeyword found
  3327.    In an instruction such as NUMERIC which requires a subkeyword (e.g.
  3328.    NUMERIC DIGITS, etc), that subkeyword was missing or invalid.
  3329.    
  3330. 26 Invalid whole number
  3331.    A function call or an instruction required an integer expression, but
  3332.    either a non-integer or an out-of-range number was supplied.  The
  3333.    magnitude of a whole number should not exceed 1999999999.
  3334.    
  3335. 27 Invalid DO syntax
  3336.  
  3337. 28 Invalid LEAVE or ITERATE
  3338.    A symbol specified after LEAVE or ITERATE was either invalid or did
  3339.    not correspond to an active loop, or there is no loop currently
  3340.    active.
  3341.    
  3342. 30 Symbol > [nnn] characters
  3343.    A variable name exceeded the implementation limit.
  3344.  
  3345. 31 Name starts with number or '.'
  3346.    The name in this case may be a label name (in which case the error is
  3347.    reported as the program is read in), or a symbol which is being given
  3348.    a value in an attempted assignment.
  3349.    
  3350. 35 Invalid expression
  3351.    A syntax error occurred during the evaluation of an expression. This
  3352.    error also sometimes results when an expression is missing.
  3353.    
  3354. 36 Unmatched '('
  3355.  
  3356. 37 Unexpected ',' or ')'
  3357.    When reported during loading or before interpreting a string (see
  3358.    error 6), this means that a comma occurred at the end of a line
  3359.    which has no successor. At other times, it means that either an
  3360.    unmatched right parenthesis was found or that a comma was found in
  3361.    an inappropriate position (such as in SAY 1,2)
  3362.    
  3363. 38 Invalid template
  3364.    A PARSE instruction has invalid syntax.
  3365.  
  3366. 39 Evaluation stack overflow (> [nn] pending operations)
  3367.    An expression was too complex to evaluate.  This usually only occurs
  3368.    if there is a large number of successive prefix operations, such as
  3369.    in: say ++++++++++++++++++++++++++++1.
  3370.  
  3371. 40 Incorrect call to routine
  3372.    A call to a function or subroutine specified the wrong number of
  3373.    parameters, or missed out a mandatory parameter, or supplied an
  3374.    inappropriate parameter for the function.
  3375.  
  3376. 41 Bad arithmetic conversion
  3377.    An arithmetic operator was used on a string which is not a number.
  3378.    
  3379. 42 Arithmetic overflow or underflow
  3380.  
  3381. 43 Routine not found: [name]
  3382.  
  3383. 44 Function did not return data
  3384.  
  3385. 48 Failure in system service
  3386.    This indicates either that a communication error occurred whilst
  3387.    dealing with the stack, or that an error occurred whilst trying to
  3388.    load a ".rxfn" file to call an external function.
  3389.    
  3390. 49 Implementation error
  3391.    The REXX interpreter has discovered a bug in itself, since some
  3392.    internal structure is inconsistent.  Naturally, you will never see
  3393.    this message. ;-)
  3394.  
  3395. Implementation-defined errors (80-99)
  3396.  
  3397. 80 No-value error
  3398.    This is the value to which the special variable rc is set when a
  3399.    SIGNAL ON NOVALUE trap is activated.
  3400.  
  3401. 81 Use of an un-implemented feature!
  3402.  
  3403. 82 Syntax error
  3404.    A syntax error has been discovered which cannot be described by any
  3405.    of the other messages (This message should never appear except when
  3406.    a LOCAL feature is being used).
  3407.  
  3408. 83 Label ends with '.'
  3409.    (this error is reported as the program is read in)
  3410.    Labels ending with '.' are disallowed since a program containing
  3411.    such a label may be unaware that foo.(3) is not a call to the
  3412.    function "foo." but a reference to a compound symbol.
  3413.    
  3414. 84 Too many arguments (> [nn])
  3415.    A call to a function or subroutine specified too many actual
  3416.    parameters for the interpreter to handle.
  3417.  
  3418. 85 ERROR condition occurred
  3419.    This code is used internally to when a "SIGNAL ON ERROR" occurs.
  3420.    You may see this message if the signal handler does not exist.
  3421.  
  3422. 86 FAILURE condition occurred
  3423.    This code is used internally to when a "SIGNAL ON ERROR" occurs.
  3424.    You may see this message if the signal handler does not exist.
  3425.  
  3426. 88 Unexpected '*/'
  3427.    This combination of symbols would usually cause an "Invalid
  3428.    expression" error, but it is singled out because the usual reason
  3429.    for this error is that a begin-comment delimiter has been omitted or
  3430.    mistyped.  This error is reported as the program is read in.
  3431.  
  3432. Unix system errors (101-198)
  3433.  
  3434.    These are the error messages which may result from a call to
  3435.    stream() with the "Describe" option.  They are defined by the Unix
  3436.    run-time library, and include such messages as "Permission denied"
  3437.    and "No such file or directory".  The number of the message is just
  3438.    100 plus its usual value in Unix.
  3439.  
  3440. Other I/O errors (100,199-210)
  3441.  
  3442.    These are the error messages which may result from a call to
  3443.    stream() with the "Describe" option and which are provided by the
  3444.    interpreter rather than by the system.
  3445.  
  3446. 100 Unknown error occurred during I/O
  3447.     An error occurred, but the system call failed to set errno to a
  3448.     meaningful value.
  3449.  
  3450. 199 End of file
  3451.  
  3452. 200 File position was out of bounds
  3453.     REXX level 4.00 does not allow you to use charin or linein to point
  3454.     to a non-existent character, or to use charout or lineout to point
  3455.     more than one byte beyond the end of file.  If you attempt this,
  3456.     then NOTREADY will be raised with this error.
  3457.  
  3458. 201 Reposition attempted on transient stream
  3459.     REXX does not allow you to reposition a stream unless it is a
  3460.     persistent stream (i.e., a regular file).  Repositioning on a pipe
  3461.     or tty is not allowed and will raise NOTREADY with this error.
  3462.  
  3463. 202 Write attempted on a read-only stream
  3464.     This error occurs if you try to write to stdin, or to any stream
  3465.     which was opened via the stream function without a name in read
  3466.     mode (for instance, with popen or fdopen).
  3467. _________________________________________________________________________
  3468.